난 당신이 바로 변수를 클릭하고 클릭하면이 변수가 참조하는 위치를 찾기 위해 많은 쉽게 "정의로 이동"것을 발견했다. MainForm을 통해 호출 된 다른 변수를 마우스 오른쪽 버튼으로 클릭하면 SearchCriteria 파일을 통해 모두 호출된다는 것을 알았습니다. SearchCriteria.cs 파일을 통해 MainForm.cs 파일에서 참조되는 addzipdir_checkbox 값을 가져 와서 SearchProcess.cs 파일에서 호출해야했습니다.
public class SearchCriteria
{
private String Corp;
private String OrderNumber;
private String Campaign;
private String City;
private String State;
private String Zip;
private String SourcePath;
private String TargetPath;
private bool SearchOR;
private bool SearchAND;
private bool addzipdirectory_checkBox;
public SearchCriteria()
{
}
public SearchCriteria(String Corp,
String OrderNumber,
String Campaign,
String City,
String State,
String Zip,
String SourcePath,
String TargetPath,
bool SearchOR,
bool SearchAND,
bool addzipdirectory_checkBox)
{
this.Corp = Corp;
this.OrderNumber = OrderNumber;
this.Campaign = Campaign;
this.City = City;
this.State = State;
this.Zip = Zip;
this.SourcePath = SourcePath;
this.TargetPath = TargetPath;
this.SearchOR = SearchOR;
this.SearchAND = SearchAND;
this.addzipdirectory_checkBox = addzipdirectory_checkBox;
}
public bool get_addzipdir_checkBox()
{
return addzipdirectory_checkBox;
}
public void set_addzipdir_checkBox(bool x)
{
addzipdirectory_checkBox = x;
}
}
가 여기에 Searchprocess.cs 파일에 내 코드입니다 :
다음은 SearchCriteria.cs 파일에 내 코드입니다 있도록 어딘가에 변수를 업데이트해야합니다 확인란을 선택 생각
// Copy the file if ANY of the search criteria have been met
if (found)
{
m_form.Invoke(m_form.m_DelegateAddString, new Object[] {"FOUND: Order_No: " + Order_No +
" barcode: " + barcode +
" MailerCode: " + MailerCode +
" AgentID: " + AgentID +
" City: " + City +
" State: " + State +
" ZIP: " + ZIP});
//passes values to TransferFile
TransferFile(directory, barcode, AgentID, ZIP);
}
} // end for that finds each matching record
}
// find and copy the file to the target directory string ZIP
private void TransferFile(string sourceDir, string filename, string AgentID, string ZIP)
{
string fullFileName = filename + ".pdf";
string fullFileNameAndPath = sourceDir + "\\" + fullFileName;
string targetFileAndPath;
if (m_sc.get_addzipdir_checkBox()==true)
{
// adds the given lead's agentid and zip code to the targetpath string
string targetzipdir = m_sc.get_TargetPath() + "\\" + AgentID + "\\" + ZIP;
// If the given lead's zip code subdirectory doesn't exist, create it.
if (!Directory.Exists(targetzipdir))
{
Directory.CreateDirectory(targetzipdir);
}
targetFileAndPath = m_sc.get_TargetPath() + "\\" + AgentID + "\\" + ZIP + "\\" + fullFileName;
} // end if addzipdir_checkBox.Equals(true)
당신 변수를 참조 할 수 있으며 다른 형식의 컨트롤은 참조 할 수 없습니다. –
줄을 추가했습니다. bool addzipdirectory_checkbox = 1; 첫 번째 if 문 아래에서 if (addzipdir_checkBox.Equals (true))하지만 여전히 searchprocess.cs 파일에서 참조 할 수 없습니다. 이 m_form.Invoke (m_form.m_DelegateAddString, 새 개체 [] 상태에서 검색 : "+ m_sc.get_State()});) 같은 가져 오기 문을 사용해야합니다. 또는 if (m_sc.get_SearchAND() == true) { m_form.Invoke (m_form.m_DelegateAddString, new Object [] {모두 검색}}); } 또는 Utility.Properties.Settings.Default에서 가져 오십시오. 지역? –