private void btnSaveContainer_Click(object sender, EventArgs e) { if (!IsAllRequiredTextFilled() || (cmbCtr3.Text.Trim() == string.Empty)) { MessageBox.Show("لطفا همه فیلدها را پر کنید"); ActiveControl = cmbBlNo; return; } try { //Save or Edit Ctr CTRViewModel ctr = new CTRViewModel { txt1 = "CTR", BolRef = int.Parse(cmbBlNo.SelectedValue.ToString()), BolNo = cmbBlNo.Text, txt2 = txtCtr1.Text, txt3 = txtCtr2.Text, txt4 = lblCtr3.Text, txt5 = txtCtr4.Text }; if (ContainerEditID == 0) { CTR.Insert(ctr); } else //Update { ctr.ID = int.Parse(dgvContainer.CurrentRow.Cells["ID"].Value.ToString()); CTR.Update(ctr); cmbBlNo.Enabled = true; } //Empty All Textboxes foreach (Control c in gbContainer.Controls) { if (c is TextBox) { c.Text = string.Empty; } } cmbCtr3.Text = ""; txtCtr4.Text = "0"; progressBar3.Value = 50; } catch (Exception ex) { MessageBox.Show(ex.Message); } finally { dgvContainer.DataSource = CTR.GetAllData(); RefreshCTR_cmb(); btnSaveContainer.Text = "ذخیره کانتینر"; ContainerEditID = 0; gbKalaStatus(); } }
private void RefreshCTR_cmb() { cmbContainerNumber.DataSource = null; cmbContainerNumber.DataSource = CTR.GetAllData(); cmbContainerNumber.DisplayMember = "txt2"; cmbContainerNumber.ValueMember = "ID"; }
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 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(); } } } } }