Exemplo n.º 1
0
        private void btnBatchDelete_Click(object sender, EventArgs e)
        {
            try
            {
                PRPDBatch obj = objPRPDBatch;
                //obj = objPRPDBatch_DL.Get(dgvPRPDbatchByState.CurrentRow.Cells["PRPDBatchID"].Value.ToString());
                if (obj != null)
                {
                    DialogResult dr = MessageBox.Show(this, "Are you sure you want to delete selected PRPD Batch\n\nClick Yes to delete", "Confirm Delete", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2);

                    if (dr == DialogResult.Yes)
                    {
                        //MR_DL objMRDL = new MR_DL(ConnectionStringClass.GetConnection());
                        //MR objMR = objMRDL.Get(obj.MRIN);
                        //if (objMR.MRNO <= 0 || objMR.MRStatus == MR.Status.Initial || objMR.MRStatus == MR.Status.Reject)
                        {
                            int res = objPRPDBatch_DL.Delete(obj.PRPDBatchID);
                            //if (objMR.MRStatus == MR.Status.Initial)
                            //{
                            //    objMR.MRStatus = MR.Status.Reject;
                            //    objMR.MRApprovedBy = CurrentUser.UserEmp;
                            //    int x = objMRDL.Update(objMR);

                            //}

                            if (res > 0)
                            {
                                dtPRPDBatches = objPRPDBatch_DL.GetDataByState_Type((PRPDBatch.PRPDBatchStatus)Enum.Parse(typeof(PRPDBatch.PRPDBatchStatus), cmbPRPDBatchStatus.SelectedValue.ToString()), PRPDBatch.PRPDType.PrimaryPreperation);

                                dgvPRPDbatchByState.AutoGenerateColumns = false;
                                dgvPRPDbatchByState.DataSource          = objSourcePRPDBatches;
                                objSourcePRPDBatches.DataSource         = dtPRPDBatches;
                                objSourcePRPDBatches.ResetBindings(true);


                                objSourceInstructions.DataSource = null;
                                objSourceInstructions.ResetBindings(false);
                                objPRPDBatch           = null;
                                btnApprove.Enabled     = false;
                                btnBatchDelete.Enabled = false;
                            }
                        }
                        //else
                        //{
                        //    MessageBox.Show(this, "MR Approved,You cant delete this Batch Files. Please contact the system administrator", "Delete Fail", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                        //}
                    }
                }
            }
            catch (Exception)
            {
                MessageBox.Show(this, "Error occured while deleting", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }