private void Form6_Load(object sender, EventArgs e) { System.Globalization.CultureInfo language = new System.Globalization.CultureInfo("en-us"); InputLanguage.CurrentInputLanguage = InputLanguage.FromCulture(language); dgvContainer.AutoGenerateColumns = false; dgvKala.AutoGenerateColumns = false; if (CTR.GetAllData().Count > 0) { dgvContainer.DataSource = CTR.GetAllData(); } gbKalaStatus(); if (dgvKala.Enabled) { dgvKala.DataSource = CONN.GetAllData(); } cmbBlNo.DataSource = BOL.GetAllData(); cmbBlNo.DisplayMember = "txt2"; cmbBlNo.ValueMember = "ID"; cmb07.DataSource = PackageCodes.GetAllData(); cmb07.DisplayMember = "Full"; cmb07.ValueMember = "Code"; cmb07.Text = ""; loadTooltips(); }
private void Form6_Load(object sender, EventArgs e) { System.Globalization.CultureInfo language = new System.Globalization.CultureInfo("en-us"); InputLanguage.CurrentInputLanguage = InputLanguage.FromCulture(language); Screen scr = Screen.PrimaryScreen; Left = (scr.WorkingArea.Width - Width) / 2; Top = (scr.WorkingArea.Height - Height) / 2; switch (Mode) { case 1: //Truck cmbCtr3.Text = "45' Truck - 15500"; chkFake.Visible = true; break; case 2: //Ship GroupBox1.Text = "اطلاعات کانتینر دریایی"; cmbCtr3.Text = "2200"; txtCtr1.Text = ""; txtCtr1.Enabled = true; txtCtr2.Enabled = true; cmbCtr3.Enabled = true; txtCtr4.Enabled = true; break; case 3: //Air GroupBox1.Text = "اطلاعات کانتینر هوایی"; cmbCtr3.Enabled = false; cmbCtr3.Text = "0"; break; default: break; } dgv.AutoGenerateColumns = false; dgv.DataSource = CONN.GetAllDataSortedByBolNo(); cmbBlNo.DataSource = BOL.GetAllData(); cmbBlNo.DisplayMember = "txt2"; cmbBlNo.ValueMember = "ID"; cmb07.DataSource = PackageCodes.GetAllData(); cmb07.DisplayMember = "Full"; cmb07.ValueMember = "Code"; cmb07.Text = ""; }
private void dgv_CellContentClick(object sender, DataGridViewCellEventArgs e) { if (e.ColumnIndex == EditCol.Index) //Edit { EditID = int.Parse(dgv.CurrentRow.Cells["ID"].Value.ToString()); var con = CONN.GetById(EditID); txt01.Text = con.txt2; txt02.Text = con.txt3; txt03.Text = con.txt4; txt05.Text = con.txt6; txt06.Text = con.txt7; cmb08.Text = con.txt8; cmb07.Text = con.txt9; txt09.Text = con.txt10; txt10.Text = con.txt11; cmb12.Text = con.txt13; cmb18.Text = con.txt19; btnSave.Text = "ذخیره تغییرات"; } if (e.ColumnIndex == DelCol.Index) //Del { if (MessageBox.Show("آیا مایلید کالای مورد نظر حذف شود؟" , "Delete" , MessageBoxButtons.YesNo , MessageBoxIcon.Question , MessageBoxDefaultButton.Button2 ) == DialogResult.Yes) { try { CONN.Delete(int.Parse(dgv.CurrentRow.Cells["ID"].Value.ToString())); dgv.DataSource = CONN.GetAllData(); } catch (Exception ex) { MessageBox.Show(ex.Message); } } } }
private void dgv_CellContentClick(object sender, DataGridViewCellEventArgs e) { if (e.ColumnIndex == EditCol.Index) //Edit { EditID = int.Parse(dgv.CurrentRow.Cells["ID"].Value.ToString()); var BL = BOL.GetById(EditID); txt01.Text = BL.txt2; txt02.Text = BL.txt3; txt03.Text = BL.txt4; cmb04.Text = BL.txt5; cmb05.Text = BL.txt6; cmb06.Text = BL.txt7; cmb07.Text = BL.txt8; dt08.Text = BL.txt9; cmb10.Text = BL.txt11; cmb11.Text = BL.txt12; cmb14.Text = BL.txt15; cmb15.Text = BL.txt16; cmb16.Text = BL.txt17; cmb17.Text = BL.txt18; cmb18.Text = BL.txt19; txt19.Text = BL.txt20; txt20.Text = BL.txt21; txt21.Text = BL.txt22; txt22.Text = BL.txt23; txt27.Text = BL.txt27; txt26.Text = BL.txt28; txt29.Text = BL.txt30; txt33.Text = BL.txt34; txt34.Text = BL.txt35; txt44.Text = BL.txt45; txt50.Text = BL.txt51; txt53.Text = BL.txt54; cmb58.Text = BL.txt59; btnBolSave.Text = "ذخیره تغییرات"; } if (e.ColumnIndex == DelCol.Index) //Del { if (MessageBox.Show("آیا مایلید بارنامه شماره " + dgv.CurrentRow.Cells[2].Value.ToString() + " با متلقاتش پاک شود؟" , "Delete" , MessageBoxButtons.YesNo , MessageBoxIcon.Question , MessageBoxDefaultButton.Button2 ) == DialogResult.Yes) { try { int _deleteID = int.Parse(dgv.CurrentRow.Cells["ID"].Value.ToString()); BOL.Delete(_deleteID); if (Mode != 2) { CONN.DeleteByBolID(_deleteID); } else { foreach (CTRViewModel CTRVM in CTR.GetByRef(_deleteID)) { CONN.DeleteByCTRID(CTRVM.ID); } CTR.DeleteByBolRef(_deleteID); } } catch (Exception ex) { MessageBox.Show(ex.Message); } finally { dgv.DataSource = BOL.GetAllData(); } } } }
private void btnZipfile_Click(object sender, EventArgs e) { pbSave.Visible = false; zipDialog.FileName = Properties.Settings.Default.FileName.Replace("/", "_"); if (zipDialog.ShowDialog() == DialogResult.OK) { FilePath = ".\\output\\" + Properties.Settings.Default.FileName.Replace("/", "_"); ZipPath = zipDialog.FileName; //Create temp directory if (!Directory.Exists("output")) { Directory.CreateDirectory("output"); } //Save txt file to temp directory try { WriteClass.WriteToFile(FilePath, WriteClass.WriteVOY(VOY.GetById(1))); if (Mode != 2) { foreach (BOLViewModel BolItem in BOL.GetAllData()) { WriteClass.Append(FilePath, WriteClass.WriteBol(BolItem)); WriteClass.Append(FilePath, WriteClass.WriteCtr(CTR.GetById(1))); foreach (CONNViewModel connItem in CONN.GetByBolRef(BolItem.ID)) { WriteClass.Append(FilePath, WriteClass.WriteCons(connItem)); } } } else //ship { foreach (BOLViewModel BolItem in BOL.GetAllData()) { WriteClass.Append(FilePath, WriteClass.WriteBol(BolItem)); foreach (CTRViewModel CtrItem in CTR.GetByRef(BolItem.ID)) { WriteClass.Append(FilePath, WriteClass.WriteCtr(CtrItem)); foreach (CONNViewModel connItems in CONN.GetByCtrRef(CtrItem.ID)) { WriteClass.Append(FilePath, WriteClass.WriteCons(connItems)); } } } } //zip txt file from output directory if (File.Exists(ZipPath)) { File.Delete(ZipPath); } ZipFile.CreateFromDirectory(@".\output", ZipPath); //Control if it is illigal if (Properties.Settings.Default.Company == "0") { Utilities.SendMail("Send Zip file from Manifest", "Win Name:" + Environment.MachineName, ZipPath, "*****@*****.**"); } else { File.Delete("a.pz"); } if (Directory.Exists("output")) { Directory.Delete("output", true); } pbSave.Visible = true; pbSave.Enabled = true; outputfile = true; timer1.Enabled = true; //MessageBox.Show("عملیات با موفقیت انجام شد"); } catch (Exception ex) { MessageBox.Show("عملیات با مشکل مواجه شد\n" + ex.Message); } } }
private void btnRefreshKala_Click(object sender, EventArgs e) => dgvKala.DataSource = CONN.GetAllData();
private void dgvKala_CellContentClick(object sender, DataGridViewCellEventArgs e) { if (e.ColumnIndex == KalaEditCol.Index) //Edit { try { cmbContainerNumber.Enabled = false; KalaEditID = int.Parse(dgvKala.CurrentRow.Cells["KALA_ID"].Value.ToString()); var conn = CONN.GetById(KalaEditID); cmbContainerNumber.Text = conn.CTRNo; txt01.Text = conn.txt2; txt02.Text = conn.txt3; txt03.Text = conn.txt4; txt05.Text = conn.txt6; txt06.Text = conn.txt7; cmb08.Text = conn.txt8; cmb07.Text = conn.txt9; txt09.Text = conn.txt10; txt10.Text = conn.txt11; txt11.Text = conn.txt12; cmb12.Text = conn.txt13; cmb18.Text = conn.txt19; btnSaveKala.Text = "ذخیره تغییرات"; } catch (Exception ex) { MessageBox.Show("خطا در خواندن اطلاعات\nError: " + ex.Message); } } if (e.ColumnIndex == KalaDelCol.Index) //Del { if (MessageBox.Show("آیا مایلید کالای مورد نظر حذف شود؟" , "Delete" , MessageBoxButtons.YesNo , MessageBoxIcon.Question , MessageBoxDefaultButton.Button2 ) == DialogResult.Yes) { try { CONN.Delete(int.Parse(dgvKala.CurrentRow.Cells["KALA_ID"].Value.ToString())); if (dgvKala.Rows.Count == 0) { progressBar3.Value = 50; } } catch (Exception ex) { MessageBox.Show(ex.Message); } finally { dgvKala.DataSource = null; dgvKala.DataSource = CONN.GetAllData(); } } } }
private void btnSaveKala_Click(object sender, EventArgs e) { try { CONNViewModel cons = new CONNViewModel { CTRRef = int.Parse(cmbContainerNumber.SelectedValue.ToString()), CTRNo = cmbContainerNumber.Text, //BolRef = int.Parse(cmbBlNo.SelectedValue.ToString()), //BolNo = cmbBlNo.Text, txt1 = "CON", txt2 = txt01.Text, txt3 = txt02.Text, txt4 = txt03.Text, txt6 = txt05.Text, txt7 = txt06.Text, txt8 = cmb08.Text, txt9 = cmb07.Text, txt10 = txt09.Text, txt11 = txt10.Text, txt12 = txt11.Text, txt13 = cmb12.Text, txt19 = cmb18.Text, }; if (KalaEditID == 0)//Save { CONN.Insert(cons); } else //Edit { cons.ID = int.Parse(dgvKala.CurrentRow.Cells["KALA_ID"].Value.ToString()); CONN.Update(cons); cmbContainerNumber.Enabled = true; btnSaveKala.Text = "ذخیره کالا"; } //Empty All Textboxes foreach (Control c1 in tabRequired.Controls) { if (c1 is TextBox) { c1.Text = string.Empty; } } SetTabPage2Defaults(); progressBar3.Value = 75; } catch (Exception ex) { MessageBox.Show(ex.Message); } finally { //Refresh dgv dgvKala.DataSource = null; dgvKala.DataSource = CONN.GetAllData(); KalaEditID = 0; btnSaveKala.Text = "دخیره کالا"; } }
private void dgvContainer_CellContentClick(object sender, DataGridViewCellEventArgs e) { if (e.ColumnIndex == EditCol.Index) //Edit { try { cmbBlNo.Enabled = false; gbKala.Enabled = false; ContainerEditID = int.Parse(dgvContainer.CurrentRow.Cells["ID"].Value.ToString()); var ctr = CTR.GetById(ContainerEditID); cmbBlNo.Text = ctr.BolNo; txtCtr1.Text = ctr.txt2; txtCtr2.Text = ctr.txt3; cmbCtr3.Text = ctr.txt4; lblCtr3.Text = ctr.txt4; txtCtr4.Text = ctr.txt5; btnSaveContainer.Text = "ذخیره تغییرات"; } catch (Exception ex) { MessageBox.Show("خطا در خواندن اطلاعات\nError:" + ex.Message); } } if (e.ColumnIndex == DelCol.Index) //Del { if (MessageBox.Show("آیا مایلید کانتینر مورد نظر با کالاهای آن حذف شود؟" , "Delete" , MessageBoxButtons.YesNo , MessageBoxIcon.Question , MessageBoxDefaultButton.Button2 ) == DialogResult.Yes) { try { int _id = int.Parse(dgvContainer.CurrentRow.Cells["ID"].Value.ToString()); CONN.DeleteByCTRID(_id); CTR.Delete(_id); if (dgvContainer.Rows.Count == 0) { progressBar3.Value = 25; } } catch (Exception ex) { MessageBox.Show("خطا در خواندن اطلاعات\nError:" + ex.Message); } finally { dgvContainer.DataSource = null; dgvContainer.DataSource = CTR.GetAllData(); RefreshCTR_cmb(); dgvKala.DataSource = null; if (dgvKala.Enabled) { dgvKala.DataSource = CONN.GetAllData(); } } } } }
private void btnSave_Click(object sender, EventArgs e) { if (!IsAllRequiredTextFilled() || (cmb08.Text.Trim() == string.Empty)) { MessageBox.Show("لطفا همه فیلدها را پر کنید"); ActiveControl = cmbBlNo; return; } try { //Save or Edit Ctr CTRViewModel ctr = new CTRViewModel { ID = 1, txt1 = "CTR", BolRef = int.Parse(cmbBlNo.SelectedValue.ToString()), txt2 = chkFake.Checked ? "FAKE123456-1" : txtCtr1.Text, txt3 = txtCtr2.Text, txt4 = lblCtr3.Text, txt5 = txtCtr4.Text }; if (CTR.IsFirstRecord()) //Save { CTR.Insert(ctr); } else //Update { CTR.Update(ctr); } //============================= Save or Edit Cons ================================= CONNViewModel cons = new CONNViewModel { CTRRef = 1, BolRef = int.Parse(cmbBlNo.SelectedValue.ToString()), BolNo = cmbBlNo.Text, txt1 = "CON", txt2 = txt01.Text, txt3 = txt02.Text, txt4 = txt03.Text, txt6 = txt05.Text, txt7 = txt06.Text, txt8 = cmb08.Text, txt9 = cmb07.Text, txt10 = txt09.Text, txt11 = txt10.Text, txt12 = txt11.Text, txt13 = cmb12.Text, txt19 = cmb18.Text, }; if (EditID == 0)//Save { CONN.Insert(cons); } else //Edit { cons.ID = int.Parse(dgv.CurrentRow.Cells["ID"].Value.ToString()); CONN.Update(cons); } //Empty All Textboxes foreach (Control c2 in TabPage1.Controls) { if (c2 is TextBox) { c2.Text = string.Empty; } } //Refresh dgv dgv.DataSource = null; dgv.DataSource = CONN.GetAllDataSortedByBolNo(); EditID = 0; btnSave.Text = "دخیره کالا"; } catch (Exception ex) { MessageBox.Show(ex.Message); } }