コード例 #1
0
        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   = "دخیره کالا";
            }
        }
コード例 #2
0
ファイル: Form4.cs プロジェクト: robmas1356/ManiFestGitHub
        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);
            }
        }