private void btnGRN_Click(object sender, EventArgs e) { try { objMTN = objMTNDL.Get(objMTN.MTNNo); if (objMTN.MTNStatus == MTN.Status.Cost) { if ((objMTN != null) && (objStore != null)) { if (objMTN.MTNItemType == MTN.ItemType.Material) { PRPDBatch_DL objPRPDBatch_DL = new PRPDBatch_DL(ConnectionStringClass.GetConnection()); PRPDBatch objPRPDBatch = objPRPDBatch_DL.Get(gvMTNList.CurrentRow.Cells["BatchID"].Value.ToString()); if (objPRPDBatch.Type == PRPDBatch.PRPDType.Rework) { objStore = objStoreDL.Get("RM_Main"); long GRNNO = objMTNDL.AddGRN(objMTN.MTNNo, MTN.Status.ReceviedGRN, CurrentUser.EmployeeID, objStore.StoreID, GRN.Type.Material, GRN.Status.Initial); MessageBox.Show(this, "Successfully Raised a GRN. The GRNNO is : " + GRNNO.ToString(), "Successful", MessageBoxButtons.OK); } else { long GRNNO = objMTNDL.AddGRN(objMTN.MTNNo, MTN.Status.ReceviedGRN, CurrentUser.EmployeeID, objStore.StoreID, GRN.Type.Material, GRN.Status.Initial); MessageBox.Show(this, "Successfully Raised a GRN. The GRNNO is : " + GRNNO.ToString(), "Successful", MessageBoxButtons.OK); } } else if (objMTN.MTNItemType == MTN.ItemType.Basic_Product) { long GRNNO = objMTNDL.AddGRN(objMTN.MTNNo, MTN.Status.ReceviedGRN, CurrentUser.EmployeeID, objStore.StoreID, GRN.Type.BasicProduct, GRN.Status.Initial); MessageBox.Show(this, "Successfully Raised a GRN. The GRNNO is : " + GRNNO.ToString(), "Successful", MessageBoxButtons.OK); } else if (objMTN.MTNItemType == MTN.ItemType.Finish_Product) { long GRNNO = objMTNDL.AddGRN(objMTN.MTNNo, MTN.Status.ReceviedGRN, CurrentUser.EmployeeID, objStore.StoreID, GRN.Type.FinishProduct, GRN.Status.Initial); MessageBox.Show(this, "Successfully Raised a GRN. The GRNNO is : " + GRNNO.ToString(), "Successful", MessageBoxButtons.OK); } bindMTNList.DataSource = objMTNDL.Get_From_PRPD_Batches(Convert.ToInt64(MTN.Type.PRPD), Convert.ToInt32(MTN.Status.Cost)); if (gvMTNList.Rows.Count > 0) { DataGridViewCellEventArgs dr = new DataGridViewCellEventArgs(1, 0); gvMTNList_CellClick(sender, dr); } else { bindItemList.DataSource = null; } } } } catch (Exception ex) { MessageBox.Show(this, ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }