//public ICollection<AsgTechnicianCallDetail> colGetAsgTechnicianCallDetail(string argAsgTechCallCode, string argPartnerCode, string argClientCode) //{ // List<AsgTechnicianCallDetail> lst = new List<AsgTechnicianCallDetail>(); // DataSet DataSetToFill = new DataSet(); // AsgTechnicianCallDetail tAsgTechnicianCallDetail = new AsgTechnicianCallDetail(); // DataSetToFill = this.GetAsgTechnicianCallDetail(argAsgTechCallCode, argPartnerCode , argClientCode); // if (DataSetToFill != null) // { // foreach (DataRow dr in DataSetToFill.Tables[0].Rows) // { // lst.Add(objCreateAsgTechnicianCallDetail(dr)); // } // } // goto Finish; //Finish: // DataSetToFill = null; // return lst; //} public AsgTechnicianCallDetailCol colGetAsgTechnicianCallDetail(string argAsgTechCallCode, string argPartnerCode, string argClientCode) { AsgTechnicianCallDetailCol AsgTechCallDetailCol = new AsgTechnicianCallDetailCol(); DataSet DataSetToFill = new DataSet(); AsgTechnicianCallDetail tAsgTechnicianCallDetail = new AsgTechnicianCallDetail(); DataSetToFill = this.GetAsgTechnicianCallDetail(argAsgTechCallCode, argPartnerCode, argClientCode); if (DataSetToFill != null) { foreach (DataRow dr in DataSetToFill.Tables[0].Rows) { AsgTechCallDetailCol.colAsgTechnicianCallDetail.Add(objCreateAsgTechnicianCallDetail(dr)); } } goto Finish; Finish: DataSetToFill = null; return(AsgTechCallDetailCol); }
public PartnerErrorResult SaveAsgTechnicianCallMaster(AsgTechnicianCallMaster argAsgTechnicianCallMaster, AsgTechnicianCallDetailCol argAsgTechCallDetailCol) { List <ErrorHandler> lstErr = new List <ErrorHandler>(); PartnerErrorResult errorcol = new PartnerErrorResult(); PartnerGoodsMovementManager objPartnerGMManager = new PartnerGoodsMovementManager(); DataAccess da = new DataAccess(); string strretValue = ""; try { da.Open_Connection(); da.BEGIN_TRANSACTION(); if (blnIsAsgTechnicianCallMasterExists(argAsgTechnicianCallMaster.AsgTechCallCode, argAsgTechnicianCallMaster.PartnerCode, argAsgTechnicianCallMaster.ClientCode, da) == false) { strretValue = InsertAsgTechnicianCallMaster(argAsgTechnicianCallMaster, da, lstErr); } else { strretValue = UpdateAsgTechnicianCallMaster(argAsgTechnicianCallMaster, da, lstErr); } foreach (ErrorHandler objerr in lstErr) { if (objerr.Type == "E") { errorcol.colErrorHandler.Add(objerr); da.ROLLBACK_TRANSACTION(); return(errorcol); } if (objerr.Type == "A") { errorcol.colErrorHandler.Add(objerr); da.ROLLBACK_TRANSACTION(); return(errorcol); } } if (strretValue != "") { string strGoodsMovementCode = ""; if (argAsgTechnicianCallMaster.AssignType.Trim() != "CALL") { strGoodsMovementCode = objPartnerGMManager.GenerateGMCode("NEW", "GM01", argAsgTechnicianCallMaster.PartnerCode, argAsgTechnicianCallMaster.ClientCode, da); } if (argAsgTechCallDetailCol.colAsgTechnicianCallDetail.Count > 0) { foreach (AsgTechnicianCallDetail objAsgTechnicianCallDetail in argAsgTechCallDetailCol.colAsgTechnicianCallDetail) { objAsgTechnicianCallDetail.AsgTechCallCode = strretValue; if (argAsgTechnicianCallMaster.AssignType.Trim() != "CALL") { objAsgTechnicianCallDetail.PGoodsMovementCode = strGoodsMovementCode; objAsgTechnicianCallDetail.GMItemNo = objAsgTechnicianCallDetail.ItemNo; } if (objAsgTechnicianCallDetail.IsDeleted == 0) { objAsgTechnicianCallDetailMan.SaveAsgTechnicianCallDetail(objAsgTechnicianCallDetail, da, lstErr); } else { /*Delete function*/ } } foreach (ErrorHandler objerr in lstErr) { if (objerr.Type == "E") { errorcol.colErrorHandler.Add(objerr); da.ROLLBACK_TRANSACTION(); return(errorcol); } if (objerr.Type == "A") { errorcol.colErrorHandler.Add(objerr); da.ROLLBACK_TRANSACTION(); return(errorcol); } } } if (argAsgTechnicianCallMaster.AssignType.Trim().ToUpper() != "CALL") { /* Partner Goods Movement Declared */ PartnerGoodsMovement objPartnerGM = new PartnerGoodsMovement(); objPartnerGM.PGoodsMovementCode = strGoodsMovementCode; objPartnerGM.PartnerGMDocTypeCode = "GM01"; objPartnerGM.FromPlantCode = ""; objPartnerGM.FromPartnerCode = ""; objPartnerGM.FromPartnerEmployeeCode = ""; objPartnerGM.FromStoreCode = ""; objPartnerGM.ToPartnerCode = Convert.ToString(argAsgTechnicianCallMaster.PartnerCode); objPartnerGM.ToPlantCode = ""; objPartnerGM.ToStoreCode = ""; objPartnerGM.ToPartnerEmployeeCode = Convert.ToString(argAsgTechnicianCallMaster.PartnerEmployeeCode); objPartnerGM.GoodsMovDate = Convert.ToDateTime(argAsgTechnicianCallMaster.AssignDate); objPartnerGM.ClientCode = argAsgTechnicianCallMaster.ClientCode; objPartnerGM.CreatedBy = argAsgTechnicianCallMaster.CreatedBy; objPartnerGM.ModifiedBy = argAsgTechnicianCallMaster.ModifiedBy; objPartnerGM.TotalQuantity = 0; objPartnerGM.PartnerCode = argAsgTechnicianCallMaster.PartnerCode; /*----------------------------------------------------------------------------------------*/ /* Partner Goods Movement Detail */ PartnerMaterialDocTypeManager objPartnerMatDocTypeMan = new PartnerMaterialDocTypeManager(); PartnerGoodsMovementDetailCol objPartnerGMCol = new PartnerGoodsMovementDetailCol(); PartnerGoodsMovSerialDetailCol objPartnerGMSerialCol = new PartnerGoodsMovSerialDetailCol(); objPartnerGMCol.colPartnerGMDetail = new List <PartnerGoodsMovementDetail>(); objPartnerGMSerialCol.colPartnerGMSerialDetail = new List <PartnerGoodsMovSerialDetail>(); DataSet dsMatDocType = null; bool IsNew = true; int iCtr = 0; int tmpItemNo = 0; foreach (AsgTechnicianCallDetail objAsgTechCallDetail in argAsgTechCallDetailCol.colAsgTechnicianCallDetail) { if (objAsgTechCallDetail.IsDeleted == 0) { dsMatDocType = new DataSet(); if (IsNew == true) { iCtr = iCtr + 1; dsMatDocType = objPartnerMatDocTypeMan.GetPartnerMaterialDocType(objAsgTechCallDetail.MaterialDocTypeCode, objAsgTechCallDetail.ClientCode, da); PartnerGoodsMovementDetail objPartnerGMDetailsnew = new PartnerGoodsMovementDetail(); objPartnerGMDetailsnew.PGoodsMovementCode = strGoodsMovementCode; objPartnerGMDetailsnew.ItemNo = iCtr; tmpItemNo = iCtr; objPartnerGMDetailsnew.MaterialCode = Convert.ToString(objAsgTechCallDetail.MaterialCode); objPartnerGMDetailsnew.MatGroup1Code = Convert.ToString(objAsgTechCallDetail.MaterialCode); objPartnerGMDetailsnew.Quantity = Convert.ToInt32(objAsgTechCallDetail.Quantity); objPartnerGMDetailsnew.UOMCode = Convert.ToString(objAsgTechCallDetail.UOMCode); objPartnerGMDetailsnew.ClientCode = Convert.ToString(objAsgTechCallDetail.ClientCode); objPartnerGMDetailsnew.CreatedBy = Convert.ToString(objAsgTechCallDetail.CreatedBy); objPartnerGMDetailsnew.ModifiedBy = Convert.ToString(objAsgTechCallDetail.ModifiedBy); objPartnerGMDetailsnew.TranRefDocCode = Convert.ToString(strretValue); objPartnerGMDetailsnew.TranRefDocItemNo = Convert.ToInt32(objAsgTechCallDetail.ItemNo); objPartnerGMDetailsnew.MaterialDocTypeCode = Convert.ToString(objAsgTechCallDetail.MaterialDocTypeCode); objPartnerGMDetailsnew.PartnerCode = Convert.ToString(objAsgTechCallDetail.PartnerCode); if (dsMatDocType != null) { if (dsMatDocType.Tables[0].Rows.Count > 0) { if (Convert.ToString(dsMatDocType.Tables[0].Rows[0]["AllowedFromStock"]).Trim() != "HIDE") { objPartnerGMDetailsnew.StockIndicator = Convert.ToString(objAsgTechCallDetail.StockIndicator); } else { objPartnerGMDetailsnew.StockIndicator = ""; } if (Convert.ToString(dsMatDocType.Tables[0].Rows[0]["AllowedToStock"]).Trim() != "HIDE") { objPartnerGMDetailsnew.ToStockIndicator = Convert.ToString(objAsgTechCallDetail.ToStockIndicator); } else { objPartnerGMDetailsnew.ToStockIndicator = ""; } if (Convert.ToString(dsMatDocType.Tables[0].Rows[0]["FromPlant"]).Trim() != "HIDE") { objPartnerGMDetailsnew.FromPlantCode = ""; } else { objPartnerGMDetailsnew.FromPlantCode = ""; } if (Convert.ToString(dsMatDocType.Tables[0].Rows[0]["FromPartner"]).Trim() != "HIDE") { objPartnerGMDetailsnew.FromPartnerCode = Convert.ToString(objAsgTechCallDetail.PartnerCode); } else { objPartnerGMDetailsnew.FromPartnerCode = ""; } if (Convert.ToString(dsMatDocType.Tables[0].Rows[0]["FromStore"]).Trim() != "HIDE") { objPartnerGMDetailsnew.FromStoreCode = Convert.ToString(objAsgTechCallDetail.StoreCode); } else { objPartnerGMDetailsnew.FromStoreCode = ""; } if (Convert.ToString(dsMatDocType.Tables[0].Rows[0]["FromEmployee"]).Trim() != "HIDE") { objPartnerGMDetailsnew.FromPartnerEmployeeCode = Convert.ToString(objAsgTechCallDetail.FromPartnerEmployeeCode); } else { objPartnerGMDetailsnew.FromPartnerEmployeeCode = ""; } if (Convert.ToString(dsMatDocType.Tables[0].Rows[0]["ToPartner"]).Trim() != "HIDE") { objPartnerGMDetailsnew.ToPartnerCode = Convert.ToString(objAsgTechCallDetail.ToPartnerCode); } else { objPartnerGMDetailsnew.ToPartnerCode = ""; } if (Convert.ToString(dsMatDocType.Tables[0].Rows[0]["ToStore"]).Trim() != "HIDE") { objPartnerGMDetailsnew.ToStoreCode = Convert.ToString(objAsgTechCallDetail.ToStoreCode); } else { objPartnerGMDetailsnew.ToStoreCode = ""; } if (Convert.ToString(dsMatDocType.Tables[0].Rows[0]["ToEmployee"]).Trim() != "HIDE") { objPartnerGMDetailsnew.ToPartnerEmployeeCode = Convert.ToString(objAsgTechCallDetail.ToPartnerEmployeeCode); } else { objPartnerGMDetailsnew.ToPartnerEmployeeCode = ""; } if (Convert.ToString(dsMatDocType.Tables[0].Rows[0]["ToPlant"]).Trim() != "HIDE") { objPartnerGMDetailsnew.ToPlantCode = ""; } else { objPartnerGMDetailsnew.ToPlantCode = ""; } if (Convert.ToString(dsMatDocType.Tables[0].Rows[0]["ToMaterialCode"]).Trim() != "HIDE") { objPartnerGMDetailsnew.ToMaterialCode = Convert.ToString(objAsgTechCallDetail.ToMaterialCode); } else { objPartnerGMDetailsnew.ToMaterialCode = ""; } } else { objPartnerGMDetailsnew.FromPlantCode = ""; objPartnerGMDetailsnew.FromPartnerCode = Convert.ToString(objAsgTechCallDetail.PartnerCode); objPartnerGMDetailsnew.FromPartnerEmployeeCode = ""; objPartnerGMDetailsnew.FromStoreCode = Convert.ToString(objAsgTechCallDetail.StoreCode); objPartnerGMDetailsnew.ToPartnerCode = Convert.ToString(objAsgTechCallDetail.ToPartnerCode); objPartnerGMDetailsnew.ToPartnerEmployeeCode = Convert.ToString(objAsgTechCallDetail.ToPartnerEmployeeCode); objPartnerGMDetailsnew.ToPlantCode = ""; objPartnerGMDetailsnew.ToStoreCode = Convert.ToString(objAsgTechCallDetail.ToStoreCode); objPartnerGMDetailsnew.ToMaterialCode = Convert.ToString(objAsgTechCallDetail.ToMaterialCode); } } objPartnerGMCol.colPartnerGMDetail.Add(objPartnerGMDetailsnew); if (objAsgTechCallDetail.SerialNo1 != "") { /*Partner Goods Movement Serial Detail*/ PartnerGoodsMovSerialDetail objPartnerGoodsMovSerialnew = new PartnerGoodsMovSerialDetail(); objPartnerGoodsMovSerialnew.PGoodsMovementCode = strGoodsMovementCode; objPartnerGoodsMovSerialnew.ItemNo = tmpItemNo; objPartnerGoodsMovSerialnew.SerialNo1 = Convert.ToString(objAsgTechCallDetail.SerialNo1); objPartnerGoodsMovSerialnew.SerialNo2 = Convert.ToString(objAsgTechCallDetail.SerialNo2); objPartnerGoodsMovSerialnew.MaterialCode = Convert.ToString(objAsgTechCallDetail.MaterialCode); objPartnerGoodsMovSerialnew.MatGroup1Code = Convert.ToString(objAsgTechCallDetail.MatGroup1Code); objPartnerGoodsMovSerialnew.RefDocCode = Convert.ToString(objAsgTechCallDetail.RefDocCode); objPartnerGoodsMovSerialnew.RefDocItemNo = Convert.ToInt32(objAsgTechCallDetail.RefDocItemNo); objPartnerGoodsMovSerialnew.RefDocType = Convert.ToString(objAsgTechCallDetail.RefDocTypeCode); objPartnerGoodsMovSerialnew.TranRefDocCode = Convert.ToString(strretValue); objPartnerGoodsMovSerialnew.TranRefDocItemNo = Convert.ToInt32(objAsgTechCallDetail.ItemNo); objPartnerGoodsMovSerialnew.IsDeleted = 0; objPartnerGoodsMovSerialnew.ClientCode = Convert.ToString(objAsgTechCallDetail.ClientCode); objPartnerGoodsMovSerialnew.CreatedBy = Convert.ToString(objAsgTechCallDetail.CreatedBy); objPartnerGoodsMovSerialnew.ModifiedBy = Convert.ToString(objAsgTechCallDetail.ModifiedBy); if (dsMatDocType != null) { if (dsMatDocType.Tables[0].Rows.Count > 0) { if (Convert.ToString(dsMatDocType.Tables[0].Rows[0]["AllowedFromStock"]).Trim() != "HIDE") { objPartnerGoodsMovSerialnew.StockIndicator = Convert.ToString(objAsgTechCallDetail.StockIndicator); } else { objPartnerGoodsMovSerialnew.StockIndicator = ""; } if (Convert.ToString(dsMatDocType.Tables[0].Rows[0]["AllowedToStock"]).Trim() != "HIDE") { objPartnerGoodsMovSerialnew.ToStockIndicator = Convert.ToString(objAsgTechCallDetail.ToStockIndicator); } else { objPartnerGoodsMovSerialnew.ToStockIndicator = ""; } if (dsMatDocType.Tables[0].Rows[0]["FromPlant"].ToString() != "HIDE") { objPartnerGoodsMovSerialnew.PlantCode = ""; } else { objPartnerGoodsMovSerialnew.PlantCode = ""; } if (dsMatDocType.Tables[0].Rows[0]["FromPartner"].ToString() != "HIDE") { objPartnerGoodsMovSerialnew.PartnerCode = Convert.ToString(objAsgTechCallDetail.PartnerCode); } else { objPartnerGoodsMovSerialnew.PartnerCode = ""; } if (dsMatDocType.Tables[0].Rows[0]["FromStore"].ToString() != "HIDE") { objPartnerGoodsMovSerialnew.StoreCode = Convert.ToString(objAsgTechCallDetail.StoreCode); } else { objPartnerGoodsMovSerialnew.StoreCode = ""; } if (dsMatDocType.Tables[0].Rows[0]["FromEmployee"].ToString() != "HIDE") { objPartnerGoodsMovSerialnew.PartnerEmployeeCode = Convert.ToString(objAsgTechCallDetail.FromPartnerEmployeeCode); } else { objPartnerGoodsMovSerialnew.PartnerEmployeeCode = ""; } if (dsMatDocType.Tables[0].Rows[0]["ToPartner"].ToString() != "HIDE") { objPartnerGoodsMovSerialnew.ToPartnerCode = Convert.ToString(objAsgTechCallDetail.ToPartnerCode); } else { objPartnerGoodsMovSerialnew.ToPartnerCode = ""; } if (dsMatDocType.Tables[0].Rows[0]["ToStore"].ToString() != "HIDE") { objPartnerGoodsMovSerialnew.ToStoreCode = Convert.ToString(objAsgTechCallDetail.ToStoreCode); } else { objPartnerGoodsMovSerialnew.ToStoreCode = ""; } if (dsMatDocType.Tables[0].Rows[0]["ToEmployee"].ToString() != "HIDE") { objPartnerGoodsMovSerialnew.ToPartnerEmployeeCode = Convert.ToString(objAsgTechCallDetail.ToPartnerEmployeeCode); } else { objPartnerGoodsMovSerialnew.ToPartnerEmployeeCode = ""; } if (dsMatDocType.Tables[0].Rows[0]["ToPlant"].ToString() != "HIDE") { objPartnerGoodsMovSerialnew.ToPlantCode = ""; } else { objPartnerGoodsMovSerialnew.ToPlantCode = ""; } if (dsMatDocType.Tables[0].Rows[0]["ToMaterialCode"].ToString() != "HIDE") { objPartnerGoodsMovSerialnew.ToMaterialCode = Convert.ToString(objAsgTechCallDetail.ToMaterialCode); } else { objPartnerGoodsMovSerialnew.ToMaterialCode = ""; } } else { objPartnerGoodsMovSerialnew.PlantCode = ""; objPartnerGoodsMovSerialnew.PartnerCode = Convert.ToString(objAsgTechCallDetail.PartnerCode); objPartnerGoodsMovSerialnew.PartnerEmployeeCode = ""; objPartnerGoodsMovSerialnew.StoreCode = Convert.ToString(objAsgTechCallDetail.StoreCode); objPartnerGoodsMovSerialnew.ToPartnerCode = Convert.ToString(objAsgTechCallDetail.ToPartnerCode); objPartnerGoodsMovSerialnew.ToPartnerEmployeeCode = Convert.ToString(objAsgTechCallDetail.ToPartnerEmployeeCode); objPartnerGoodsMovSerialnew.ToPlantCode = ""; objPartnerGoodsMovSerialnew.ToStoreCode = Convert.ToString(objAsgTechCallDetail.ToStoreCode); objPartnerGoodsMovSerialnew.ToMaterialCode = Convert.ToString(objAsgTechCallDetail.ToMaterialCode); } } objPartnerGMSerialCol.colPartnerGMSerialDetail.Add(objPartnerGoodsMovSerialnew); /*----------------------------------------------------------------------------------------------------------*/ } } } /*-----------------------------------------------------------------------------------------------------------*/ } /*Partner Goods Movement Save*/ objPartnerGMManager.SavePartnerGoodsMovement(objPartnerGM, objPartnerGMCol, objPartnerGMSerialCol, da, lstErr); foreach (ErrorHandler objerr in lstErr) { if (objerr.Type == "E") { errorcol.colErrorHandler.Add(objerr); da.ROLLBACK_TRANSACTION(); return(errorcol); } if (objerr.Type == "A") { errorcol.colErrorHandler.Add(objerr); da.ROLLBACK_TRANSACTION(); return(errorcol); } } } } da.COMMIT_TRANSACTION(); } catch (Exception ex) { if (da != null) { da.ROLLBACK_TRANSACTION(); } objErrorHandler.Type = ErrorConstant.strAboartType; objErrorHandler.MsgId = 0; objErrorHandler.Module = ErrorConstant.strInsertModule; objErrorHandler.ModulePart = ErrorConstant.strMasterModule; objErrorHandler.Message = ex.Message.ToString(); objErrorHandler.RowNo = 0; objErrorHandler.FieldName = ""; objErrorHandler.LogCode = ""; lstErr.Add(objErrorHandler); errorcol.colErrorHandler.Add(objErrorHandler); } finally { if (da != null) { da.Close_Connection(); da = null; } } return(errorcol); }