Пример #1
0
        private void btnApprove_Click_1(object sender, EventArgs e)
        {
            try
            {
                DialogResult Result = new DialogResult();

                Result = MessageBox.Show(this, "Are You Sure You Want to Approve the Batch", "Approve Batch", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

                if (Result == DialogResult.Yes)
                {
                    if (objPRPDBatch != null)
                    {
                        PRPDBatch obj = objPRPDBatch;
                        //obj = objPRPDBatch_DL.Get(dgvPRPDbatchByState.CurrentRow.Cells["PRPDBatchID"].Value.ToString());


                        long res = GenerateMR(objPRPDBatch);
                        int  x   = 0;
                        if (res > 0)
                        {
                            obj.MRIN = res;
                            x        = objPRPDBatch_DL.UpdateMR(obj.PRPDBatchID, res);
                        }

                        obj.Status = PRPDBatch.PRPDBatchStatus.Approved;
                        obj.PRPDBatchApprovedBy = CurrentUser.UserEmp;
                        int res1 = objPRPDBatch_DL.Update_Apprve(obj);
                        if (x >= 0)
                        {
                            MessageBox.Show(this, "PRPD batch approved. MR sent to " + objStore.StoreName + "\nMR No :- " + obj.MRIN.ToString(), "Successful", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        }


                        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         = null;
                        objSourcePRPDBatches.ResetBindings(false);
                        objSourceInstructions.DataSource = null;
                        objSourceInstructions.ResetBindings(false);
                        objPRPDBatch           = null;
                        btnApprove.Enabled     = false;
                        btnBatchDelete.Enabled = false;



                        this.cmbPRPDBatchStatus_SelectedIndexChanged(sender, e);
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(this, "Error occured while Approving", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }