public CustomList <CmnWorkFlowDetail> GetAllCmnWorkFlowDetail(Int32 WorkFlowID) { return(CmnWorkFlowDetail.GetAllCmnWorkFlowDetail(WorkFlowID)); }
/// <summary> /// Save Data To Database /// <para>Use it when save data through ORM</para> /// </summary> public string SaveUpdateApprovalSetup(CmnWorkFlowMaster workFlowMaster, List <CmnWorkFlowDetail> workFlowDetail) { GenericFactory_EF_CmnWorkFlowMaster = new CmnWorkFlowMaster_EF(); GenericFactory_EF_CmnWorkFlowDetail = new CmnWorkFlowDetail_EF(); string result = string.Empty; if (workFlowMaster.WorkFlowID > 0) { using (TransactionScope transaction = new TransactionScope()) { try { //start for Update in CmnWorkFlowMaster int workFlowID = workFlowMaster.WorkFlowID; IEnumerable <CmnWorkFlowMaster> lstCmnWorkFlowMaster = GenericFactory_EF_CmnWorkFlowMaster.FindBy(m => m.WorkFlowID == workFlowID).ToList(); CmnWorkFlowMaster objCmnWorkFlowMaster = new CmnWorkFlowMaster(); foreach (CmnWorkFlowMaster wfm in lstCmnWorkFlowMaster) { wfm.MenuID = workFlowMaster.MenuID; wfm.IsActive = workFlowMaster.IsActive; wfm.BranchID = workFlowMaster.BranchID; wfm.CompanyID = workFlowMaster.CompanyID; wfm.UpdateOn = DateTime.Now; wfm.UpdatePc = HostService.GetIP(); objCmnWorkFlowMaster = wfm; } GenericFactory_EF_CmnWorkFlowMaster.Update(objCmnWorkFlowMaster); GenericFactory_EF_CmnWorkFlowMaster.Save(); // end for Update in CmnWorkFlowMaster List <CmnWorkFlowDetail> lstCmnWorkFlowDetail = new List <CmnWorkFlowDetail>(); foreach (CmnWorkFlowDetail wfd in workFlowDetail) { CmnWorkFlowDetail objCmnWorkFlowDetail = GenericFactory_EF_CmnWorkFlowDetail.FindBy(m => m.WorkFlowDetailID == wfd.WorkFlowDetailID).FirstOrDefault(); objCmnWorkFlowDetail.CompanyID = wfd.CompanyID; objCmnWorkFlowDetail.EmployeeID = wfd.EmployeeID; objCmnWorkFlowDetail.Sequence = wfd.Sequence; objCmnWorkFlowDetail.StatusID = wfd.StatusID; objCmnWorkFlowDetail.IsDeleted = false; objCmnWorkFlowDetail.UpdateOn = wfd.UpdateOn; objCmnWorkFlowDetail.UpdatePc = HostService.GetIP(); lstCmnWorkFlowDetail.Add(objCmnWorkFlowDetail); } GenericFactory_EF_CmnWorkFlowDetail.UpdateList(lstCmnWorkFlowDetail); GenericFactory_EF_CmnWorkFlowDetail.Save(); transaction.Complete(); result = workFlowMaster.WorkFlowID.ToString(); } catch (Exception e) { e.ToString(); result = ""; } } } else { using (TransactionScope transaction = new TransactionScope()) { //...........START new maxId........// //int NextId = Convert.ToInt16(GenericFactory_EF_CmnWorkFlowMaster.getMaxID("CmnWorkFlowMaster")); //int nextWorkFlowDetailID = Convert.ToInt16(GenericFactory_EF_CmnWorkFlowDetail.getMaxID("CmnWorkFlowDetail")); //...........START new maxId........// long NextId = Convert.ToInt64(GenericFactory_EF_CmnWorkFlowMaster.getMaxID("CmnWorkFlowMaster")); long FirstDigit = 0; long OtherDigits = 0; long nextDetailId = Convert.ToInt64(GenericFactory_EF_CmnWorkFlowDetail.getMaxID("CmnWorkFlowDetail")); FirstDigit = Convert.ToInt64(nextDetailId.ToString().Substring(0, 1)); OtherDigits = Convert.ToInt64(nextDetailId.ToString().Substring(1, nextDetailId.ToString().Length - 1)); //..........END new maxId.........// //..........END new maxId.........// try { workFlowMaster.WorkFlowID = Convert.ToInt16(NextId); workFlowMaster.CreateOn = DateTime.Now; workFlowMaster.CreatePc = HostService.GetIP(); List <CmnWorkFlowDetail> lstWorkFlowDetail = new List <CmnWorkFlowDetail>(); foreach (CmnWorkFlowDetail wfd in workFlowDetail) { CmnWorkFlowDetail objCmnWorkFlowDetail = new CmnWorkFlowDetail(); objCmnWorkFlowDetail.WorkFlowDetailID = Convert.ToInt16(FirstDigit + "" + OtherDigits); //nextWorkFlowDetailID; objCmnWorkFlowDetail.WorkFlowID = Convert.ToInt16(NextId); //NextId; objCmnWorkFlowDetail.CompanyID = workFlowMaster.CompanyID ?? 0; objCmnWorkFlowDetail.DBID = wfd.DBID; objCmnWorkFlowDetail.EmployeeID = wfd.EmployeeID; objCmnWorkFlowDetail.Sequence = wfd.Sequence; objCmnWorkFlowDetail.StatusID = wfd.StatusID; objCmnWorkFlowDetail.IsDeleted = false; objCmnWorkFlowDetail.CreateBy = wfd.CreateBy; objCmnWorkFlowDetail.CreateOn = DateTime.Now; objCmnWorkFlowDetail.CreatePc = HostService.GetIP(); objCmnWorkFlowDetail.Transfer = false; lstWorkFlowDetail.Add(objCmnWorkFlowDetail); // nextWorkFlowDetailID++; OtherDigits++; } GenericFactory_EF_CmnWorkFlowMaster.Insert(workFlowMaster); GenericFactory_EF_CmnWorkFlowMaster.Save(); //............Update MaxID.................// GenericFactory_EF_CmnWorkFlowMaster.updateMaxID("CmnWorkFlowMaster", Convert.ToInt64(NextId)); GenericFactory_EF_CmnWorkFlowDetail.InsertList(lstWorkFlowDetail); GenericFactory_EF_CmnWorkFlowDetail.Save(); //............Update MaxID.................// GenericFactory_EF_CmnWorkFlowDetail.updateMaxID("CmnWorkFlowDetail", Convert.ToInt16(FirstDigit + "" + (OtherDigits - 1))); // GenericFactory_EF_SalPIDetail.updateMaxID("SalPIDetail", Convert.ToInt64(FirstDigit + "" + (OtherDigits - 1))); transaction.Complete(); result = NextId.ToString(); } catch (Exception e) { e.ToString(); result = ""; } } } return(result); }