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 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); } }