public long GenerateMR(PRPDBatch objPRPD) { MR objMR = new MR(); MRMaterialCollec objMRMatCollec = new MRMaterialCollec(); MRFinishProductCollec objMRFinishProductCollec = new MRFinishProductCollec(); MRBasicProductCollec objMRBasicProductCollec = new MRBasicProductCollec(); BatchMR objBatchMR = new BatchMR(); Department_DL objDepDL = new Department_DL(ConnectionStringClass.GetConnection()); MR_DL objMRDL = new MR_DL(ConnectionStringClass.GetConnection()); MRMaterial_DL objMRMaterialDL = new MRMaterial_DL(ConnectionStringClass.GetConnection()); Store_DL objStoreDL = new Store_DL(ConnectionStringClass.GetConnection()); try { objMR.MRDate = DateTime.Now; objMR.MRDepartmentFrom = objDepDL.GetByDepType("PRPD"); objMR.MREnterdBy = CurrentUser.UserEmp; objMR.MRStatus = MR.Status.Initial; // Store objStore = (Store)cmbStores.SelectedItem; //objMR.MRStore = objStoreDL.Get(objStore.StoreID); objMR.MRType = MR.Type.Material; objMR.MRRemarks = "Material Requition(Materials) for PRPD Batch NO " + objPRPD.PRPDBatchID.ToString(); MRMaterial obj = new MRMaterial(); obj.Description = "PRPD Batch Material Requition"; obj.Material = objPRPD.PRPDBatchMaterial; obj.MRBINNo = ""; obj.ReqdQty = objPRPD.PRPDBatchQty; long MRNO = objMRDL.Add(objMR); if (MRNO > 0) { objMR.MRNO = MRNO; obj.MR = objMR; objMRMaterialDL.Add(obj); } return(MRNO); } catch (Exception ex) { return(0); } }