Exemplo n.º 1
0
        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();
                    }
                }
            }
        }
Exemplo n.º 2
0
        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();
                        }
                    }
                }
            }
        }