private void btnSearch_Click(object sender, EventArgs e) { if (lstSearch.SelectedIndex >= 0) { if (txtType.ForeColor != Color.Black) { txtCDName.ForeColor = Color.Black; txtDateOfWrite.ForeColor = Color.Black; txtSpecifications.ForeColor = Color.Black; txtType.ForeColor = Color.Black; txtNumber.ForeColor = Color.Black; txtBailment.ForeColor = Color.Black; txtDateOfBailment.ForeColor = Color.Black; } // Clear All Pic --\|/--\|/--\|/--\|/--\|/--\|/--\|/--\|/--\|/--\|/--\|/--\|/--\|/--\|/--\|/--\|/--\|/--\|/ picDataCd.Visible = false; picDataDvd.Visible = false; picDriver.Visible = false; picFloppyDisk.Visible = false; picFloppyZipDisk.Visible = false; picMultimediaCd.Visible = false; picMultimediaDvd.Visible = false; picMusicCd.Visible = false; picMusicDvd.Visible = false; picOtherCD.Visible = false; picOtherCdRw.Visible = false; picOtherDvd.Visible = false; picOtherDvdRw.Visible = false; picPictureCd.Visible = false; picPictureDvd.Visible = false; picVideoCd.Visible = false; picVideoDvd.Visible = false; picWindows.Visible = false; //--\|/--\|/--\|/--\|/--\|/--\|/--\|/--\|/--\|/--\|/--\|/--\|/--\|/--\|/--\|/--\|/--\|/--\|/--\|/--\|/--\|/ string bufferName = lstSearch.SelectedItem.ToString(); CdInfo Read = (CdInfo)Form1.arrCdInfo[bufferName]; SelectTypePic(Read.Type); txtCDName.Text = Read.CdName; txtDateOfWrite.Text = Read.DateOfCd; txtNumber.Text = Read.NumberOfCd; txtSpecifications.Text = Read.Specifications; txtType.Text = Read.Type; if (string.Compare(Read.Bailment, "true", true) == 0) { CdBailment BRead = (CdBailment)Form1.arrCdBailment[bufferName]; txtBailment.Text = "Yes (By: " + BRead.BailmentName + ")"; txtDateOfBailment.Text = BRead.DateOfBailment; } else { txtBailment.Text = "No"; txtDateOfBailment.Text = "-- -- --"; } } else { return; } }
public void LoadCD() { // Load CdInfo string[] LcName, LcDate, LcNumberCd, LcType, LcSpecifications, LcB; // LcB ==> Load cd Bailment. LcName = System.IO.File.ReadAllLines((Form1.patchCD + @"\BehzadCName.sys")); LcDate = System.IO.File.ReadAllLines((Form1.patchCD + @"\BehzadCDate.sys")); LcNumberCd = System.IO.File.ReadAllLines((Form1.patchCD + @"\BehzadCNumberCd.sys")); LcType = System.IO.File.ReadAllLines((Form1.patchCD + @"\BehzadCType.sys")); LcSpecifications = System.IO.File.ReadAllLines((Form1.patchCD + @"\BehzadCSpecifications.sys")); LcB = System.IO.File.ReadAllLines((Form1.patchCD + @"\BehzadCdBailment.sys")); long i = LcName.LongCount() - 1; for (; i >= 0; i--) { CdInfo Copy = new CdInfo(); Copy.CdName = LcName[i]; Copy.DateOfCd = LcDate[i]; Copy.NumberOfCd = LcNumberCd[i]; Copy.Specifications = LcSpecifications[i]; Copy.Type = LcType[i]; Copy.Bailment = LcB[i]; if (Form1.arrCdInfo.Contains(Copy.CdName) == false) { Form1.arrCdInfo.Add(Copy.CdName, Copy); } else { DialogResult returnE = MessageBox.Show("The CD by Name (" + Copy.CdName + ") Already is Exist in Club!" + "\nAre you to continue Import other CDs of patch (" + Form1.patchCD + ") ?", "Error Repeat in Import Data" , MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2); if (returnE == DialogResult.No) { return; } else if (returnE == DialogResult.Yes) { continue; } } } // Show In ListBox foreach (CdInfo name in Form1.arrCdInfo.Values) { lstDisplay.Items.Add(name); } // Load Cd Bailment string[] LcBName, LcBDate, LcBType, LcBCdNumber, LcBCdName; // LcBCdName ==> Load cd Bailment Cd Name LcBName = System.IO.File.ReadAllLines((Form1.patchCD + @"\BehzadCBName.sys")); LcBDate = System.IO.File.ReadAllLines((Form1.patchCD + @"\BehzadCBDate.sys")); LcBType = System.IO.File.ReadAllLines((Form1.patchCD + @"\BehzadCBType.sys")); LcBCdName = System.IO.File.ReadAllLines((Form1.patchCD + @"\BehzadCBCdName.sys")); LcBCdNumber = File.ReadAllLines((Form1.patchCD + @"\BehzadCBNumberCd.sys")); i = LcBName.LongCount() - 1; for (; i >= 0; i--) { CdBailment Copy = new CdBailment(); Copy.BailmentName = LcBName[i]; Copy.CdName = LcBCdName[i]; Copy.DateOfBailment = LcBDate[i]; Copy.BailmentCdType = LcBType[i]; Copy.NumberCd = LcBCdNumber[i]; if (Form1.arrCdBailment.Contains(Copy.CdName) == false) { Form1.arrCdBailment.Add(Copy.CdName, Copy); } else { DialogResult returnE = MessageBox.Show("The Bailment CD by Name (" + Copy.CdName + ") Already is Exist in Bailment Club!" + "\nAre you to continue Import other CDs of patch (" + Form1.patchCD + ") ?", "Error Repeat in Import Data" , MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2); if (returnE == DialogResult.No) { return; } else if (returnE == DialogResult.Yes) { continue; } } } }
private void btnAdd_Click(object sender, EventArgs e) { if (txtFullUserName.Text == "" || txtFullUserName.Text == "نام کامل امانت گیرنده") { MessageBox.Show("Full Bailment User Name TextBox is Empty! \nPlease Fill it.", "Error TextBox Empty"); AddOk.Visible = false; picError.Visible = true; txtFullUserName.Focus(); txtFullUserName.SelectAll(); return; } else if (txtNumberCd.Text == "" || txtNumberCd.Text == "CD - DVD تعداد") { MessageBox.Show("Number CD - DVD TextBox is Empty! \nPlease Fill it.", "Error TextBox Empty"); AddOk.Visible = false; picError.Visible = true; txtNumberCd.Focus(); txtNumberCd.SelectAll(); return; } else if (combCdName.Text == "" || combCdName.Text == "CD - DVD نام") { MessageBox.Show("CD - DVD Name TextBox is Empty! \nPlease Fill it.", "Error TextBox Empty"); AddOk.Visible = false; picError.Visible = true; combCdName.Focus(); combCdName.SelectAll(); return; } else if (txtTypeCd.Text == "CD - DVD نوع") { DialogResult R = MessageBox.Show("Please Search CD - DVD Type by your CD - DVD Name, Fill Button!" + "Press Rerty Button to Search it , Etc Click On Cancel", "Error TextBox Empty" , MessageBoxButtons.RetryCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2); if (R == DialogResult.Retry) { SearchTypeCD(); } else if (R == DialogResult.Cancel) { AddOk.Visible = false; picError.Visible = true; combCdName.Focus(); return; } } //------------------------------------------------------------------------------------------------------------------------------------- // No Error go Add -> else { //--\|/--\|/--\|/--\|/--\|/--\|/--\|/--\|/--\|/--\|/--\|/--\|/--\|/--\|/--\|/--\|/--\|/--\|/--\|/-- // Find Correctly Number of CD - DVD in TextBox Number CD - DVD Boolean FindNumber = false; foreach (string readN in FormAddC.strNumberCombo) { if (readN == txtNumberCd.Text) { FindNumber = true; break; } } if (FindNumber != true) { MessageBox.Show("The Number of CD - DVD is Not Correct! \n Please Change it.", "Warning Not Found Correctly Number Of CD - DVD" , MessageBoxButtons.OK, MessageBoxIcon.Warning); AddOk.Visible = false; picError.Visible = true; txtNumberCd.Focus(); txtNumberCd.SelectAll(); return; } //--\|/--\|/--\|/--\|/--\|/--\|/--\|/--\|/--\|/--\|/--\|/--\|/--\|/--\|/--\|/--\|/--\|/--\|/--\|/-- // //================================================================================================= //Search the correct CD - DVD Name of Form1.arrCdInfo if (Form1.arrCdInfo.ContainsKey(combCdName.Text) == true) { Hashtable write = new Hashtable(); write.Add(combCdName.Text, Form1.arrCdInfo[combCdName.Text]); CdInfo ChangeData = new CdInfo(); foreach (CdInfo reW in write.Values) { if (reW.Bailment == "false") { if (txtTypeCd.Text == reW.Type) { Form1.SavedCdInfo = false; CdBailment AddC = new CdBailment(); AddC.NumberCd = txtNumberCd.Text; AddC.BailmentName = txtFullUserName.Text; AddC.DateOfBailment = dateTimePicker1.Value.ToLongDateString(); AddC.CdName = reW.CdName; AddC.BailmentCdType = reW.Type; ChangeData = reW; ChangeData.Bailment = "true"; Form1.arrCdInfo.Remove(ChangeData.CdName); Form1.arrCdInfo.Add(ChangeData.CdName, ChangeData); Form1.arrCdBailment.Add(AddC.CdName, AddC); picError.Visible = false; AddOk.Visible = true; ClearText(false); return; } else { DialogResult S = MessageBox.Show("Your CD - DVD Name no Match by Type CD - DVD!" + "\nPlease Press Ok to Search Again Etc press Cancel", "Error No Matching Entered Data" , MessageBoxButtons.OKCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2); if (S == DialogResult.OK) { SearchTypeCD(); } else { combCdName.Focus(); combCdName.SelectAll(); } AddOk.Visible = false; picError.Visible = true; return; } } else { MessageBox.Show("Your CD - DVD Already is Exist in Bailment List", "Warning Already Exist" , MessageBoxButtons.OK, MessageBoxIcon.Warning); AddOk.Visible = false; picError.Visible = true; txtFullUserName.Focus(); txtFullUserName.SelectAll(); return; } } } else { MessageBox.Show("Not Found Any CD - DVD for your CD - DVD Name Please Change it.", "Error Not Found" , MessageBoxButtons.OK, MessageBoxIcon.Stop); AddOk.Visible = false; picError.Visible = true; return; } //================================================================================================= } }