예제 #1
0
 private void btnDelete_Click(object sender, EventArgs e)
 {
     try
     {
         if (objMR != null)
         {
             DialogResult dr = MessageBox.Show(this, "Are you sure you want to Delete selected MR?\n\nClick yes to Delete", "Confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
             if (dr == DialogResult.Yes)
             {
                 int x = objMRDL.Delete(objMR.MRNO);
                 if (x > 0)
                 {
                     MessageBox.Show(this, "Material Requition Deleted", "Deleted", MessageBoxButtons.OK, MessageBoxIcon.Information);
                     Clear();
                 }
             }
         }
         else
         {
             MessageBox.Show(this, "Please select a MR before click Delete", "Select a MR", MessageBoxButtons.OK, MessageBoxIcon.Information);
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(this, ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
예제 #2
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            try
            {
                if (objRPDBatch != null)
                {
                    DialogResult dr = MessageBox.Show(this, "Are you sure you want to delete Selected RPD 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());
                        if (objRPDBatch.RPDBatchMR.MRStatus == MR.Status.Initial || objRPDBatch.RPDBatchMR.MRStatus == MR.Status.Reject)
                        {
                            if (objRPDBatch.RPDBatchMR.MRStatus == MR.Status.Initial)
                            {
                                objMRDL.Delete(objRPDBatch.RPDBatchMR.MRNO);
                            }

                            int res = objRPDBatchDL.Delete(objRPDBatch.RPDBatchID);

                            if (res > 0)
                            {
                                bindRPDBatch.DataSource = objRPDBatchDL.GetDataViewByState(Status, true);
                                ClearForm();
                                objRPDBatch = null;
                            }
                        }
                        else
                        {
                            MessageBox.Show(this, "Material Requsition In Prograss, You can't delete this RPD Batch File\nReject the Material Requsition and Try again.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        }
                    }
                }
                else
                {
                    MessageBox.Show(this, "Please select the RPD Batch file you want to delete", "Empty Selection", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
            }
            catch (Exception)
            {
                MessageBox.Show(this, "Error occured while deleting", "Error", MessageBoxButtons.OK, MessageBoxIcon.Question);
            }
        }