public void SavePartnerGoodsMovSerialDetail(PartnerGoodsMovSerialDetail argPartnerGoodsMovSerialDetail, DataAccess da, List <ErrorHandler> lstErr)
 {
     try
     {
         if (blnIsPartnerGoodsMovSerialDetailExists(argPartnerGoodsMovSerialDetail.PGoodsMovementCode, argPartnerGoodsMovSerialDetail.ItemNo, argPartnerGoodsMovSerialDetail.MaterialCode, argPartnerGoodsMovSerialDetail.SerialNo1, argPartnerGoodsMovSerialDetail.ClientCode, da) == false)
         {
             InsertPartnerGoodsMovSerialDetail(argPartnerGoodsMovSerialDetail, da, lstErr);
         }
         else
         {
             //UpdatePartnerGoodsMovSerialDetail(argPartnerGoodsMovSerialDetail, da, lstErr);
         }
     }
     catch (Exception ex)
     {
         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);
     }
 }
        private PartnerGoodsMovSerialDetail objCreatePartnerGoodsMovSerialDetail(DataRow dr)
        {
            PartnerGoodsMovSerialDetail tPartnerGoodsMovSerialDetail = new PartnerGoodsMovSerialDetail();

            tPartnerGoodsMovSerialDetail.SetObjectInfo(dr);

            return(tPartnerGoodsMovSerialDetail);
        }
        public PartnerGoodsMovSerialDetail objGetPartnerGoodsMovSerialDetail(string argPGoodsMovementCode, int argItemNo, string argMaterialCode, string argSerialNo1, string argClientCode)
        {
            PartnerGoodsMovSerialDetail argPartnerGoodsMovSerialDetail = new PartnerGoodsMovSerialDetail();
            DataSet DataSetToFill = new DataSet();

            if (argPGoodsMovementCode.Trim() == "")
            {
                goto ErrorHandlers;
            }

            if (argItemNo <= 0)
            {
                goto ErrorHandlers;
            }

            if (argMaterialCode.Trim() == "")
            {
                goto ErrorHandlers;
            }

            if (argSerialNo1.Trim() == "")
            {
                goto ErrorHandlers;
            }

            if (argClientCode.Trim() == "")
            {
                goto ErrorHandlers;
            }

            DataSetToFill = this.GetPartnerGoodsMovSerialDetail(argPGoodsMovementCode, argItemNo, argMaterialCode, argSerialNo1, argClientCode);

            if (DataSetToFill.Tables[0].Rows.Count <= 0)
            {
                goto Finish;
            }

            argPartnerGoodsMovSerialDetail = this.objCreatePartnerGoodsMovSerialDetail((DataRow)DataSetToFill.Tables[0].Rows[0]);

            goto Finish;

ErrorHandlers:

Finish:
            DataSetToFill = null;


            return(argPartnerGoodsMovSerialDetail);
        }
        //public ICollection<PartnerGoodsMovSerialDetail> colGetPartnerGoodsMovSerialDetail(string argPGoodsMovementCode, int argItemNo, string argClientCode)
        //{
        //    List<PartnerGoodsMovSerialDetail> lst = new List<PartnerGoodsMovSerialDetail>();
        //    DataSet DataSetToFill = new DataSet();
        //    PartnerGoodsMovSerialDetail tPartnerGoodsMovSerialDetail = new PartnerGoodsMovSerialDetail();

        //    DataSetToFill = this.GetPartnerGoodsMovSerialDetail(argPGoodsMovementCode, argItemNo, argClientCode);

        //    if (DataSetToFill != null)
        //    {
        //        foreach (DataRow dr in DataSetToFill.Tables[0].Rows)
        //        {
        //            lst.Add(objCreatePartnerGoodsMovSerialDetail(dr));
        //        }
        //    }
        //    goto Finish;

        //Finish:
        //    DataSetToFill = null;


        //    return lst;
        //}

        public void colGetPartnerGoodsMovSerialDetail(string argPGoodsMovementCode, string argClientCode, ref PartnerGoodsMovSerialDetailCol argPartnerGoodsMovSerialDetailCol)
        {
            DataSet DataSetToFill = new DataSet();
            PartnerGoodsMovSerialDetail tPartnerGoodsMovSerialDetail = new PartnerGoodsMovSerialDetail();

            DataSetToFill = this.GetPartnerGoodsMovSerialDetail(argPGoodsMovementCode, argClientCode);

            if (DataSetToFill != null)
            {
                foreach (DataRow dr in DataSetToFill.Tables[0].Rows)
                {
                    argPartnerGoodsMovSerialDetailCol.colPartnerGMSerialDetail.Add(objCreatePartnerGoodsMovSerialDetail(dr));
                }
            }
            goto Finish;

Finish:
            DataSetToFill = null;
        }
        public PartnerErrorResult SaveDCanabalizeMaster(DCanabalizeMaster argDCanabalizeMaster, DCanabalizeDetailsCol argDCanabalizeDetailsCol)
        {
            List <ErrorHandler>           lstErr                  = new List <ErrorHandler>();
            PartnerErrorResult            errorcol                = new PartnerErrorResult();
            PartnerGoodsMovementManager   objPartnerGMManager     = new PartnerGoodsMovementManager();
            PartnerMaterialDocTypeManager objPartnerMatDocTypeMan = new PartnerMaterialDocTypeManager();

            DataAccess da = new DataAccess();

            string strretValue            = "";
            string strProductGoodsMovCode = "";
            string strSpareGoodsMovCode   = "";

            DataSet dsMatDocType = null;

            try
            {
                da.Open_Connection();
                da.BEGIN_TRANSACTION();
                if (blnIsDCanabalizeMasterExists(argDCanabalizeMaster.DCanabalizeDocNo, argDCanabalizeMaster.PartnerCode, argDCanabalizeMaster.ClientCode, da) == false)
                {
                    if (argDCanabalizeMaster.PGoodsMovementCode == "NEW")
                    {
                        if (argDCanabalizeMaster.MaterialDocTypeCode != "")
                        {
                            strProductGoodsMovCode = objPartnerGMManager.GenerateGMCode("NEW", "GM01", argDCanabalizeMaster.PartnerCode, argDCanabalizeMaster.ClientCode, da);
                            argDCanabalizeMaster.PGoodsMovementCode = strProductGoodsMovCode;
                            argDCanabalizeMaster.GMItemNo           = 1;
                        }
                        else
                        {
                            argDCanabalizeMaster.PGoodsMovementCode = "";
                            argDCanabalizeMaster.GMItemNo           = 0;
                        }
                    }


                    strretValue = InsertDCanabalizeMaster(argDCanabalizeMaster, da, lstErr);
                }
                else
                {
                    strretValue = UpdateDCanabalizeMaster(argDCanabalizeMaster, 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 != "")
                {
                    //if (argSerializeStockMissingPartsCol.colSerializeStockMissingParts.Count > 0)
                    //{

                    //    foreach (SerializeStockMissingParts objSerializeStockMissingParts in argSerializeStockMissingPartsCol.colSerializeStockMissingParts)
                    //    {
                    //        if (Convert.ToString(objSerializeStockMissingParts.SerialNo).Trim() == Convert.ToString(argDCanabalizeMaster.SerialNo).Trim())
                    //        {
                    //            objSerializeStockMissingPartsManager.SaveSerializeStockMissingParts(objSerializeStockMissingParts, da, lstErr);
                    //        }
                    //    }

                    //}



                    if (argDCanabalizeDetailsCol.colDCanabalizeDetails.Count > 0)
                    {
                        foreach (DCanabalizeDetails objDCanabalizeDetails in argDCanabalizeDetailsCol.colDCanabalizeDetails)
                        {
                            if (objDCanabalizeDetails.IsDeleted == 0)
                            {
                                if (objDCanabalizeDetails.PGoodsMovementCode == "NEW")
                                {
                                    strSpareGoodsMovCode = objPartnerGMManager.GenerateGMCode("NEW", "GM01", argDCanabalizeMaster.PartnerCode, argDCanabalizeMaster.ClientCode, da);
                                    objDCanabalizeDetails.PGoodsMovementCode = strSpareGoodsMovCode;
                                    objDCanabalizeDetails.GMItemNo           = objDCanabalizeDetails.DCanabalizeItemNo;
                                }

                                objDCanabalizeDetails.DCanabalizeDocNo = strretValue;
                                objDCanabalizeDetailsManager.SaveDCanabalizeDetails(objDCanabalizeDetails, da, lstErr);
                            }
                            else
                            {
                                /***************************/

                                /*** Delete Fucntion ***/

                                /***************************/
                            }
                        }

                        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);
                            }
                        }
                    }


                    /* Partner Goods Movement Declared for Spares */
                    if (argDCanabalizeDetailsCol.colDCanabalizeDetails.Count > 0)
                    {
                        PartnerGoodsMovement objPartnerSpareGM = new PartnerGoodsMovement();
                        objPartnerSpareGM.PGoodsMovementCode      = strSpareGoodsMovCode;
                        objPartnerSpareGM.PartnerGMDocTypeCode    = "GM01";
                        objPartnerSpareGM.FromPlantCode           = "";
                        objPartnerSpareGM.FromPartnerCode         = Convert.ToString(argDCanabalizeMaster.PartnerCode);
                        objPartnerSpareGM.FromPartnerEmployeeCode = "";
                        objPartnerSpareGM.FromStoreCode           = "";
                        objPartnerSpareGM.ToPartnerCode           = Convert.ToString(argDCanabalizeMaster.PartnerCode);
                        objPartnerSpareGM.ToPlantCode             = "";
                        objPartnerSpareGM.ToStoreCode             = "";
                        objPartnerSpareGM.ToPartnerEmployeeCode   = "";
                        objPartnerSpareGM.ClientCode    = argDCanabalizeMaster.ClientCode;
                        objPartnerSpareGM.CreatedBy     = argDCanabalizeMaster.CreatedBy;
                        objPartnerSpareGM.ModifiedBy    = argDCanabalizeMaster.ModifiedBy;
                        objPartnerSpareGM.TotalQuantity = 0;
                        objPartnerSpareGM.PartnerCode   = Convert.ToString(argDCanabalizeMaster.PartnerCode);
                        objPartnerSpareGM.GoodsMovDate  = Convert.ToDateTime(argDCanabalizeMaster.DCanablizeDate);

                        /*----------------------------------------------------------------------------------------*/
                        /* Partner Goods Movement Detail */
                        PartnerGoodsMovementDetailCol  objPartnerSpareGMCol       = new PartnerGoodsMovementDetailCol();
                        PartnerGoodsMovSerialDetailCol objPartnerSpareGMSerialCol = new PartnerGoodsMovSerialDetailCol();

                        objPartnerSpareGMCol.colPartnerGMDetail             = new List <PartnerGoodsMovementDetail>();
                        objPartnerSpareGMSerialCol.colPartnerGMSerialDetail = new List <PartnerGoodsMovSerialDetail>();
                        bool IsNew     = true;
                        int  iCtr      = 0;
                        int  tmpItemNo = 0;
                        foreach (DCanabalizeDetails objDCanabalizeDetails in argDCanabalizeDetailsCol.colDCanabalizeDetails)
                        {
                            if (objDCanabalizeDetails.IsDeleted == 0)
                            {
                                dsMatDocType = new DataSet();
                                iCtr         = iCtr + 1;
                                tmpItemNo    = iCtr;
                                if (IsNew == true)
                                {
                                    dsMatDocType = objPartnerMatDocTypeMan.GetPartnerMaterialDocType(objDCanabalizeDetails.MaterialDocTypeCode, objDCanabalizeDetails.ClientCode, da);

                                    PartnerGoodsMovementDetail objPartnerGMDetailsnew = new PartnerGoodsMovementDetail();
                                    objPartnerGMDetailsnew.PGoodsMovementCode  = strSpareGoodsMovCode;
                                    objPartnerGMDetailsnew.ItemNo              = tmpItemNo;
                                    objPartnerGMDetailsnew.MaterialCode        = Convert.ToString(objDCanabalizeDetails.MaterialCode);
                                    objPartnerGMDetailsnew.MatGroup1Code       = Convert.ToString(objDCanabalizeDetails.MatGroup1Code);
                                    objPartnerGMDetailsnew.StockIndicator      = Convert.ToString(objDCanabalizeDetails.StockIndicator);
                                    objPartnerGMDetailsnew.ToStockIndicator    = Convert.ToString(objDCanabalizeDetails.ToStockIndicator);
                                    objPartnerGMDetailsnew.Quantity            = Convert.ToInt32(objDCanabalizeDetails.Quantity);
                                    objPartnerGMDetailsnew.UOMCode             = Convert.ToString(objDCanabalizeDetails.UOMCode);
                                    objPartnerGMDetailsnew.ClientCode          = Convert.ToString(objDCanabalizeDetails.ClientCode);
                                    objPartnerGMDetailsnew.CreatedBy           = Convert.ToString(objDCanabalizeDetails.CreatedBy);
                                    objPartnerGMDetailsnew.ModifiedBy          = Convert.ToString(objDCanabalizeDetails.ModifiedBy);
                                    objPartnerGMDetailsnew.TranRefDocCode      = Convert.ToString(strretValue);
                                    objPartnerGMDetailsnew.TranRefDocItemNo    = Convert.ToInt32(objDCanabalizeDetails.DCanabalizeItemNo);
                                    objPartnerGMDetailsnew.MaterialDocTypeCode = Convert.ToString(objDCanabalizeDetails.MaterialDocTypeCode);
                                    objPartnerGMDetailsnew.PartnerCode         = Convert.ToString(objDCanabalizeDetails.PartnerCode);

                                    if (dsMatDocType != null)
                                    {
                                        if (dsMatDocType.Tables[0].Rows.Count > 0)
                                        {
                                            if (dsMatDocType.Tables[0].Rows[0]["FromPlant"].ToString() != "HIDE")
                                            {
                                                objPartnerGMDetailsnew.FromPlantCode = "";
                                            }
                                            else
                                            {
                                                objPartnerGMDetailsnew.FromPlantCode = "";
                                            }

                                            if (dsMatDocType.Tables[0].Rows[0]["FromPartner"].ToString() != "HIDE")
                                            {
                                                objPartnerGMDetailsnew.FromPartnerCode = Convert.ToString(objDCanabalizeDetails.PartnerCode);
                                            }
                                            else
                                            {
                                                objPartnerGMDetailsnew.FromPartnerCode = "";
                                            }

                                            if (dsMatDocType.Tables[0].Rows[0]["FromStore"].ToString() != "HIDE")
                                            {
                                                objPartnerGMDetailsnew.FromStoreCode = Convert.ToString(objDCanabalizeDetails.StoreCode);
                                            }
                                            else
                                            {
                                                objPartnerGMDetailsnew.FromStoreCode = "";
                                            }

                                            if (dsMatDocType.Tables[0].Rows[0]["FromEmployee"].ToString() != "HIDE")
                                            {
                                                objPartnerGMDetailsnew.FromPartnerEmployeeCode = Convert.ToString(objDCanabalizeDetails.PartnerEmployeeCode);
                                            }
                                            else
                                            {
                                                objPartnerGMDetailsnew.FromPartnerEmployeeCode = "";
                                            }

                                            if (dsMatDocType.Tables[0].Rows[0]["ToPartner"].ToString() != "HIDE")
                                            {
                                                objPartnerGMDetailsnew.ToPartnerCode = Convert.ToString(objDCanabalizeDetails.PartnerCode);
                                            }
                                            else
                                            {
                                                objPartnerGMDetailsnew.ToPartnerCode = "";
                                            }

                                            if (dsMatDocType.Tables[0].Rows[0]["ToStore"].ToString() != "HIDE")
                                            {
                                                objPartnerGMDetailsnew.ToStoreCode = Convert.ToString(objDCanabalizeDetails.ToStoreCode);
                                            }
                                            else
                                            {
                                                objPartnerGMDetailsnew.ToStoreCode = "";
                                            }

                                            if (dsMatDocType.Tables[0].Rows[0]["ToEmployee"].ToString() != "HIDE")
                                            {
                                                objPartnerGMDetailsnew.ToPartnerEmployeeCode = Convert.ToString(objDCanabalizeDetails.ToPartnerEmployeeCode);
                                            }
                                            else
                                            {
                                                objPartnerGMDetailsnew.ToPartnerEmployeeCode = "";
                                            }

                                            if (dsMatDocType.Tables[0].Rows[0]["ToPlant"].ToString() != "HIDE")
                                            {
                                                objPartnerGMDetailsnew.ToPlantCode = "";
                                            }
                                            else
                                            {
                                                objPartnerGMDetailsnew.ToPlantCode = "";
                                            }

                                            if (dsMatDocType.Tables[0].Rows[0]["ToMaterialCode"].ToString() != "HIDE")
                                            {
                                                objPartnerGMDetailsnew.ToMaterialCode = Convert.ToString(objDCanabalizeDetails.MaterialCode);
                                            }
                                            else
                                            {
                                                objPartnerGMDetailsnew.ToMaterialCode = "";
                                            }
                                        }
                                        else
                                        {
                                            objPartnerGMDetailsnew.FromPlantCode           = "";
                                            objPartnerGMDetailsnew.FromPartnerCode         = Convert.ToString(objDCanabalizeDetails.PartnerCode);
                                            objPartnerGMDetailsnew.FromPartnerEmployeeCode = Convert.ToString(objDCanabalizeDetails.PartnerEmployeeCode);
                                            objPartnerGMDetailsnew.FromStoreCode           = Convert.ToString(objDCanabalizeDetails.StoreCode);
                                            objPartnerGMDetailsnew.ToPartnerCode           = Convert.ToString(objDCanabalizeDetails.PartnerCode);
                                            objPartnerGMDetailsnew.ToPartnerEmployeeCode   = Convert.ToString(objDCanabalizeDetails.ToPartnerEmployeeCode);
                                            objPartnerGMDetailsnew.ToPlantCode             = "";
                                            objPartnerGMDetailsnew.ToStoreCode             = Convert.ToString(objDCanabalizeDetails.ToStoreCode);
                                            objPartnerGMDetailsnew.ToMaterialCode          = Convert.ToString(objDCanabalizeDetails.MaterialCode);
                                        }
                                    }

                                    objPartnerSpareGMCol.colPartnerGMDetail.Add(objPartnerGMDetailsnew);
                                    /*Partner Goods Movement Serial Detail*/
                                    if (objDCanabalizeDetails.SerialNo1 != "")
                                    {
                                        /*Partner Goods Movement Serial Detail*/

                                        PartnerGoodsMovSerialDetail objPartnerGoodsMovSerialnew = new PartnerGoodsMovSerialDetail();
                                        objPartnerGoodsMovSerialnew.PGoodsMovementCode = strSpareGoodsMovCode;
                                        objPartnerGoodsMovSerialnew.ItemNo             = tmpItemNo;
                                        objPartnerGoodsMovSerialnew.SerialNo1          = Convert.ToString(objDCanabalizeDetails.SerialNo1);
                                        objPartnerGoodsMovSerialnew.SerialNo2          = Convert.ToString("");
                                        objPartnerGoodsMovSerialnew.MaterialCode       = Convert.ToString(objDCanabalizeDetails.MaterialCode);
                                        objPartnerGoodsMovSerialnew.MatGroup1Code      = Convert.ToString(objDCanabalizeDetails.MatGroup1Code);
                                        objPartnerGoodsMovSerialnew.RefDocCode         = Convert.ToString(objDCanabalizeDetails.RefDocCode);
                                        objPartnerGoodsMovSerialnew.RefDocItemNo       = Convert.ToInt32(objDCanabalizeDetails.RefDocItemNo);
                                        objPartnerGoodsMovSerialnew.RefDocType         = Convert.ToString(objDCanabalizeDetails.RefDocTypeCode);
                                        objPartnerGoodsMovSerialnew.TranRefDocCode     = Convert.ToString(strretValue);
                                        objPartnerGoodsMovSerialnew.TranRefDocItemNo   = Convert.ToInt32(objDCanabalizeDetails.DCanabalizeItemNo);
                                        objPartnerGoodsMovSerialnew.IsDeleted          = 0;
                                        objPartnerGoodsMovSerialnew.ClientCode         = Convert.ToString(objDCanabalizeDetails.ClientCode);
                                        objPartnerGoodsMovSerialnew.CreatedBy          = Convert.ToString(objDCanabalizeDetails.CreatedBy);
                                        objPartnerGoodsMovSerialnew.ModifiedBy         = Convert.ToString(objDCanabalizeDetails.ModifiedBy);
                                        objPartnerGoodsMovSerialnew.StockIndicator     = Convert.ToString(objDCanabalizeDetails.StockIndicator);
                                        objPartnerGoodsMovSerialnew.ToStockIndicator   = Convert.ToString(objDCanabalizeDetails.ToStockIndicator);


                                        if (dsMatDocType != null)
                                        {
                                            if (dsMatDocType.Tables[0].Rows.Count > 0)
                                            {
                                                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(objDCanabalizeDetails.PartnerCode);
                                                }
                                                else
                                                {
                                                    objPartnerGoodsMovSerialnew.PartnerCode = "";
                                                }

                                                if (dsMatDocType.Tables[0].Rows[0]["FromStore"].ToString() != "HIDE")
                                                {
                                                    objPartnerGoodsMovSerialnew.StoreCode = Convert.ToString(objDCanabalizeDetails.StoreCode);
                                                }
                                                else
                                                {
                                                    objPartnerGoodsMovSerialnew.StoreCode = "";
                                                }

                                                if (dsMatDocType.Tables[0].Rows[0]["FromEmployee"].ToString() != "HIDE")
                                                {
                                                    objPartnerGoodsMovSerialnew.PartnerEmployeeCode = Convert.ToString(objDCanabalizeDetails.PartnerEmployeeCode);
                                                }
                                                else
                                                {
                                                    objPartnerGoodsMovSerialnew.PartnerEmployeeCode = "";
                                                }

                                                if (dsMatDocType.Tables[0].Rows[0]["ToPartner"].ToString() != "HIDE")
                                                {
                                                    objPartnerGoodsMovSerialnew.ToPartnerCode = Convert.ToString(objDCanabalizeDetails.PartnerCode);
                                                }
                                                else
                                                {
                                                    objPartnerGoodsMovSerialnew.ToPartnerCode = "";
                                                }

                                                if (dsMatDocType.Tables[0].Rows[0]["ToStore"].ToString() != "HIDE")
                                                {
                                                    objPartnerGoodsMovSerialnew.ToStoreCode = Convert.ToString(objDCanabalizeDetails.ToStoreCode);
                                                }
                                                else
                                                {
                                                    objPartnerGoodsMovSerialnew.ToStoreCode = "";
                                                }

                                                if (dsMatDocType.Tables[0].Rows[0]["ToEmployee"].ToString() != "HIDE")
                                                {
                                                    objPartnerGoodsMovSerialnew.ToPartnerEmployeeCode = Convert.ToString(objDCanabalizeDetails.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(objDCanabalizeDetails.MaterialCode);
                                                }
                                                else
                                                {
                                                    objPartnerGoodsMovSerialnew.ToMaterialCode = "";
                                                }
                                            }
                                            else
                                            {
                                            }
                                        }

                                        objPartnerSpareGMSerialCol.colPartnerGMSerialDetail.Add(objPartnerGoodsMovSerialnew);
                                    }
                                }
                            }
                        }
                        /*Partner Spare Goods Movement Save*/
                        if (objPartnerSpareGMCol.colPartnerGMDetail.Count > 0)
                        {
                            objPartnerGMManager.SavePartnerGoodsMovement(objPartnerSpareGM, objPartnerSpareGMCol, objPartnerSpareGMSerialCol, 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);
        }
Пример #6
0
        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);
        }
        public PartnerErrorResult SaveCallClosingDetails(CallClosingMaster argCallClosingMaster, CallClosingDetailCol argCallClosingDetailCol, CallBillingDocMaster argCallBillingDocMaster, CallBillingDocCol argCallBillingDocCol, string argPartnerCode, string argClientCode, string argUserName)
        {
            List <ErrorHandler>         lstErr                      = new List <ErrorHandler>();
            PartnerErrorResult          errorcol                    = new PartnerErrorResult();
            PartnerGoodsMovementManager objPartnerGMManager         = new PartnerGoodsMovementManager();
            CallClosingMasterManager    objCallClosingMasterManager = new CallClosingMasterManager();
            DataAccess da          = new DataAccess();
            string     strRetValue = "";

            try
            {
                da.Open_Connection();
                da.BEGIN_TRANSACTION();

                string strGoodsMovementCode = "";
                int    ictr = 0;
                strGoodsMovementCode = objPartnerGMManager.GenerateGMCode("NEW", "GM01", argPartnerCode, argClientCode, da);

                if (argCallClosingMaster != null)
                {
                    objCallClosingMasterManager.SaveCallClosingMaster(argCallClosingMaster, 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);
                    }
                }

                foreach (CallClosingDetails argCallClosingDetails in argCallClosingDetailCol.colCallClosingDetail)
                {
                    ictr = ictr + 1;

                    if (blnIsCallClosingDetailsExists(argCallClosingDetails.CallClosingCode, argCallClosingDetails.CallCode, argCallClosingDetails.CallItemNo, argCallClosingDetails.PartnerCode, argCallClosingDetails.ClientCode, da) == false)
                    {
                        argCallClosingDetails.PGoodsMovementCode = strGoodsMovementCode;
                        argCallClosingDetails.GMItemNo           = ictr;

                        InsertCallClosingDetails(argCallClosingDetails, da, lstErr);
                    }
                    else
                    {
                        UpdateCallClosingDetails(argCallClosingDetails, 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);
                    }
                }

                /*--------------------Billing Document---------------------------------------------------------------*/

                if (argCallBillingDocMaster != null)
                {
                    if (argCallBillingDocCol.colCallBillingDoc.Count > 0)
                    {
                        string srtNewCallBillingDocCode = "";
                        srtNewCallBillingDocCode = objCallBillingDocMasterManager.GenerateCallBillingDocCode(argCallBillingDocMaster.CallBillingDocCode, argCallBillingDocMaster.CallBillingDocTypeCode, argCallBillingDocMaster.PartnerCode, argCallBillingDocMaster.ClientCode, da);

                        argCallBillingDocMaster.CallBillingDocCode = srtNewCallBillingDocCode;
                        strRetValue = objCallBillingDocMasterManager.SaveCallBillingDocMaster(argCallBillingDocMaster, 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 != "")
                        {
                            foreach (CallBillingDoc objCallBillingDoc in argCallBillingDocCol.colCallBillingDoc)
                            {
                                objCallBillingDoc.CallBillingDocCode = strRetValue;
                                objCallBillingDocManager.SaveCallBillingDoc(objCallBillingDoc, 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);
                                }
                            }
                        }
                    }
                }

                /*--------------------------------------------------------------------------------------------*/



                /* Partner Goods Movement Declared */
                PartnerGoodsMovement objPartnerGM = new PartnerGoodsMovement();

                objPartnerGM.PGoodsMovementCode      = strGoodsMovementCode;
                objPartnerGM.PartnerGMDocTypeCode    = "GM01";
                objPartnerGM.FromPlantCode           = "";
                objPartnerGM.FromPartnerCode         = argPartnerCode;
                objPartnerGM.FromPartnerEmployeeCode = "";
                objPartnerGM.FromStoreCode           = "";
                objPartnerGM.ToPartnerCode           = "";
                objPartnerGM.ToPlantCode             = "";
                objPartnerGM.ToStoreCode             = "";
                objPartnerGM.ToPartnerEmployeeCode   = "";
                objPartnerGM.ClientCode    = argClientCode;
                objPartnerGM.CreatedBy     = argUserName;
                objPartnerGM.ModifiedBy    = argUserName;
                objPartnerGM.TotalQuantity = 0;
                objPartnerGM.PartnerCode   = Convert.ToString(argPartnerCode);
                objPartnerGM.GoodsMovDate  = Convert.ToDateTime(DateTime.Now);
                /*----------------------------------------------------------------------------------------*/
                /* 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     tmpItemNo    = 0;

                ictr = 0;
                foreach (CallClosingDetails argCallClosingDetails in argCallClosingDetailCol.colCallClosingDetail)
                {
                    if (argCallClosingDetails.IsDeleted == 0)
                    {
                        dsMatDocType = new DataSet();
                        if (IsNew == true)
                        {
                            ictr         = ictr + 1;
                            dsMatDocType = objPartnerMatDocTypeMan.GetPartnerMaterialDocType(argCallClosingDetails.MaterialDocTypeCode, argCallClosingDetails.ClientCode, da);

                            PartnerGoodsMovementDetail objPartnerGMDetailsnew = new PartnerGoodsMovementDetail();
                            objPartnerGMDetailsnew.PGoodsMovementCode = strGoodsMovementCode;
                            objPartnerGMDetailsnew.ItemNo             = ictr;
                            tmpItemNo = ictr;
                            objPartnerGMDetailsnew.MaterialCode        = Convert.ToString(argCallClosingDetails.MaterialCode);
                            objPartnerGMDetailsnew.MatGroup1Code       = Convert.ToString(argCallClosingDetails.MatGroup1Code);
                            objPartnerGMDetailsnew.StockIndicator      = Convert.ToString(argCallClosingDetails.StockIndicator);
                            objPartnerGMDetailsnew.ToStockIndicator    = Convert.ToString("");
                            objPartnerGMDetailsnew.Quantity            = Convert.ToInt32(argCallClosingDetails.Quantity);
                            objPartnerGMDetailsnew.UOMCode             = Convert.ToString(argCallClosingDetails.UOMCode);
                            objPartnerGMDetailsnew.ClientCode          = Convert.ToString(argCallClosingDetails.ClientCode);
                            objPartnerGMDetailsnew.CreatedBy           = Convert.ToString(argCallClosingDetails.CreatedBy);
                            objPartnerGMDetailsnew.ModifiedBy          = Convert.ToString(argCallClosingDetails.ModifiedBy);
                            objPartnerGMDetailsnew.TranRefDocCode      = Convert.ToString(argCallClosingDetails.CallClosingCode);
                            objPartnerGMDetailsnew.TranRefDocItemNo    = Convert.ToInt32(ictr);
                            objPartnerGMDetailsnew.MaterialDocTypeCode = Convert.ToString(argCallClosingDetails.MaterialDocTypeCode);
                            objPartnerGMDetailsnew.PartnerCode         = Convert.ToString(argPartnerCode);


                            if (dsMatDocType != null)
                            {
                                if (dsMatDocType.Tables[0].Rows.Count > 0)
                                {
                                    if (dsMatDocType.Tables[0].Rows[0]["FromPlant"].ToString() != "Hide")
                                    {
                                        objPartnerGMDetailsnew.FromPlantCode = "";
                                    }
                                    else
                                    {
                                        objPartnerGMDetailsnew.FromPlantCode = "";
                                    }

                                    if (dsMatDocType.Tables[0].Rows[0]["FromPartner"].ToString() != "Hide")
                                    {
                                        objPartnerGMDetailsnew.FromPartnerCode = Convert.ToString(argCallClosingDetails.PartnerCode);
                                    }
                                    else
                                    {
                                        objPartnerGMDetailsnew.FromPartnerCode = "";
                                    }

                                    if (dsMatDocType.Tables[0].Rows[0]["FromStore"].ToString() != "Hide")
                                    {
                                        objPartnerGMDetailsnew.FromStoreCode = Convert.ToString(argCallClosingDetails.StoreCode);
                                    }
                                    else
                                    {
                                        objPartnerGMDetailsnew.FromStoreCode = "";
                                    }

                                    if (dsMatDocType.Tables[0].Rows[0]["FromEmployee"].ToString() != "Hide")
                                    {
                                        objPartnerGMDetailsnew.FromPartnerEmployeeCode = "";
                                    }
                                    else
                                    {
                                        objPartnerGMDetailsnew.FromPartnerEmployeeCode = "";
                                    }

                                    if (dsMatDocType.Tables[0].Rows[0]["ToPartner"].ToString() != "Hide")
                                    {
                                        objPartnerGMDetailsnew.ToPartnerCode = Convert.ToString("");
                                    }
                                    else
                                    {
                                        objPartnerGMDetailsnew.ToPartnerCode = "";
                                    }

                                    if (dsMatDocType.Tables[0].Rows[0]["ToStore"].ToString() != "Hide")
                                    {
                                        objPartnerGMDetailsnew.ToStoreCode = Convert.ToString("");
                                    }
                                    else
                                    {
                                        objPartnerGMDetailsnew.ToStoreCode = "";
                                    }

                                    if (dsMatDocType.Tables[0].Rows[0]["ToEmployee"].ToString() != "Hide")
                                    {
                                        objPartnerGMDetailsnew.ToPartnerEmployeeCode = Convert.ToString("");
                                    }
                                    else
                                    {
                                        objPartnerGMDetailsnew.ToPartnerEmployeeCode = "";
                                    }

                                    if (dsMatDocType.Tables[0].Rows[0]["ToPlant"].ToString() != "Hide")
                                    {
                                        objPartnerGMDetailsnew.ToPlantCode = "";
                                    }
                                    else
                                    {
                                        objPartnerGMDetailsnew.ToPlantCode = "";
                                    }

                                    if (dsMatDocType.Tables[0].Rows[0]["ToMaterialCode"].ToString() != "Hide")
                                    {
                                        objPartnerGMDetailsnew.ToMaterialCode = Convert.ToString("");
                                    }
                                    else
                                    {
                                        objPartnerGMDetailsnew.ToMaterialCode = "";
                                    }
                                }
                                else
                                {
                                    objPartnerGMDetailsnew.FromPlantCode           = "";
                                    objPartnerGMDetailsnew.FromPartnerCode         = Convert.ToString(argCallClosingDetails.PartnerCode);
                                    objPartnerGMDetailsnew.FromPartnerEmployeeCode = "";
                                    objPartnerGMDetailsnew.FromStoreCode           = Convert.ToString(argCallClosingDetails.StoreCode);
                                    objPartnerGMDetailsnew.ToPartnerCode           = Convert.ToString("");
                                    objPartnerGMDetailsnew.ToPartnerEmployeeCode   = Convert.ToString("");
                                    objPartnerGMDetailsnew.ToPlantCode             = "";
                                    objPartnerGMDetailsnew.ToStoreCode             = Convert.ToString("");
                                    objPartnerGMDetailsnew.ToMaterialCode          = Convert.ToString("");
                                }
                            }
                            objPartnerGMCol.colPartnerGMDetail.Add(objPartnerGMDetailsnew);

                            /*Partner Goods Movement Serial Detail*/

                            PartnerGoodsMovSerialDetail objPartnerGoodsMovSerialnew = new PartnerGoodsMovSerialDetail();
                            objPartnerGoodsMovSerialnew.PGoodsMovementCode = strGoodsMovementCode;
                            objPartnerGoodsMovSerialnew.ItemNo             = tmpItemNo;
                            objPartnerGoodsMovSerialnew.SerialNo1          = Convert.ToString(argCallClosingDetails.SerialNo1);
                            objPartnerGoodsMovSerialnew.SerialNo2          = Convert.ToString(argCallClosingDetails.SerialNo2);
                            objPartnerGoodsMovSerialnew.MaterialCode       = Convert.ToString(argCallClosingDetails.MaterialCode);
                            objPartnerGoodsMovSerialnew.MatGroup1Code      = Convert.ToString(argCallClosingDetails.MatGroup1Code);
                            objPartnerGoodsMovSerialnew.RefDocCode         = Convert.ToString(argCallClosingDetails.CallCode);
                            objPartnerGoodsMovSerialnew.RefDocItemNo       = Convert.ToInt32(argCallClosingDetails.CallItemNo);
                            objPartnerGoodsMovSerialnew.RefDocType         = Convert.ToString("");
                            objPartnerGoodsMovSerialnew.TranRefDocCode     = Convert.ToString(argCallClosingDetails.CallClosingCode);
                            objPartnerGoodsMovSerialnew.TranRefDocItemNo   = Convert.ToInt32(ictr);
                            objPartnerGoodsMovSerialnew.IsDeleted          = 0;
                            objPartnerGoodsMovSerialnew.ClientCode         = Convert.ToString(argCallClosingDetails.ClientCode);
                            objPartnerGoodsMovSerialnew.CreatedBy          = Convert.ToString(argCallClosingDetails.CreatedBy);
                            objPartnerGoodsMovSerialnew.ModifiedBy         = Convert.ToString(argCallClosingDetails.ModifiedBy);
                            objPartnerGoodsMovSerialnew.StockIndicator     = Convert.ToString(argCallClosingDetails.StockIndicator);
                            objPartnerGoodsMovSerialnew.ToStockIndicator   = Convert.ToString(argCallClosingDetails.StockIndicator);

                            if (dsMatDocType != null)
                            {
                                if (dsMatDocType.Tables[0].Rows.Count > 0)
                                {
                                    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(argCallClosingDetails.PartnerCode);
                                    }
                                    else
                                    {
                                        objPartnerGoodsMovSerialnew.PartnerCode = "";
                                    }

                                    if (dsMatDocType.Tables[0].Rows[0]["FromStore"].ToString() != "Hide")
                                    {
                                        objPartnerGoodsMovSerialnew.StoreCode = Convert.ToString(argCallClosingDetails.StoreCode);
                                    }
                                    else
                                    {
                                        objPartnerGoodsMovSerialnew.StoreCode = "";
                                    }

                                    if (dsMatDocType.Tables[0].Rows[0]["FromEmployee"].ToString() != "Hide")
                                    {
                                        objPartnerGoodsMovSerialnew.PartnerEmployeeCode = "";
                                    }
                                    else
                                    {
                                        objPartnerGoodsMovSerialnew.PartnerEmployeeCode = "";
                                    }

                                    if (dsMatDocType.Tables[0].Rows[0]["ToPartner"].ToString() != "Hide")
                                    {
                                        objPartnerGoodsMovSerialnew.ToPartnerCode = Convert.ToString("");
                                    }
                                    else
                                    {
                                        objPartnerGoodsMovSerialnew.ToPartnerCode = "";
                                    }

                                    if (dsMatDocType.Tables[0].Rows[0]["ToStore"].ToString() != "Hide")
                                    {
                                        objPartnerGoodsMovSerialnew.ToStoreCode = Convert.ToString("");
                                    }
                                    else
                                    {
                                        objPartnerGoodsMovSerialnew.ToStoreCode = "";
                                    }

                                    if (dsMatDocType.Tables[0].Rows[0]["ToEmployee"].ToString() != "Hide")
                                    {
                                        objPartnerGoodsMovSerialnew.ToPartnerEmployeeCode = Convert.ToString("");
                                    }
                                    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("");
                                    }
                                    else
                                    {
                                        objPartnerGoodsMovSerialnew.ToMaterialCode = "";
                                    }
                                }
                                else
                                {
                                    objPartnerGoodsMovSerialnew.PlantCode             = "";
                                    objPartnerGoodsMovSerialnew.PartnerCode           = Convert.ToString(argCallClosingDetails.PartnerCode);
                                    objPartnerGoodsMovSerialnew.PartnerEmployeeCode   = "";
                                    objPartnerGoodsMovSerialnew.StoreCode             = Convert.ToString(argCallClosingDetails.StoreCode);
                                    objPartnerGoodsMovSerialnew.ToPartnerCode         = Convert.ToString("");
                                    objPartnerGoodsMovSerialnew.ToPartnerEmployeeCode = Convert.ToString("");
                                    objPartnerGoodsMovSerialnew.ToPlantCode           = "";
                                    objPartnerGoodsMovSerialnew.ToStoreCode           = Convert.ToString("");
                                    objPartnerGoodsMovSerialnew.ToMaterialCode        = Convert.ToString("");
                                }
                            }

                            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);
        }
        public void UpdatePartnerGoodsMovSerialDetail(PartnerGoodsMovSerialDetail argPartnerGoodsMovSerialDetail, DataAccess da, List <ErrorHandler> lstErr)
        {
            SqlParameter[] param = new SqlParameter[28];
            param[0]  = new SqlParameter("@PGoodsMovementCode", argPartnerGoodsMovSerialDetail.PGoodsMovementCode);
            param[1]  = new SqlParameter("@ItemNo", argPartnerGoodsMovSerialDetail.ItemNo);
            param[2]  = new SqlParameter("@MaterialCode", argPartnerGoodsMovSerialDetail.MaterialCode);
            param[3]  = new SqlParameter("@MatGroup1Code", argPartnerGoodsMovSerialDetail.MatGroup1Code);
            param[4]  = new SqlParameter("@SerialNo1", argPartnerGoodsMovSerialDetail.SerialNo1);
            param[5]  = new SqlParameter("@SerialNo2", argPartnerGoodsMovSerialDetail.SerialNo2);
            param[6]  = new SqlParameter("@PartnerCode", argPartnerGoodsMovSerialDetail.PartnerCode);
            param[7]  = new SqlParameter("@StoreCode", argPartnerGoodsMovSerialDetail.StoreCode);
            param[8]  = new SqlParameter("@PartnerEmployeeCode", argPartnerGoodsMovSerialDetail.PartnerEmployeeCode);
            param[9]  = new SqlParameter("@PlantCode", argPartnerGoodsMovSerialDetail.PlantCode);
            param[10] = new SqlParameter("@StockIndicator", argPartnerGoodsMovSerialDetail.StockIndicator);

            param[11] = new SqlParameter("@ToPlantCode", argPartnerGoodsMovSerialDetail.ToPlantCode);
            param[12] = new SqlParameter("@ToPartnerCode", argPartnerGoodsMovSerialDetail.ToPartnerCode);
            param[13] = new SqlParameter("@ToStoreCode", argPartnerGoodsMovSerialDetail.ToStoreCode);
            param[14] = new SqlParameter("@ToStockIndicator", argPartnerGoodsMovSerialDetail.ToStockIndicator);
            param[15] = new SqlParameter("@ToPartnerEmployeeCode", argPartnerGoodsMovSerialDetail.ToPartnerEmployeeCode);
            param[16] = new SqlParameter("@ToMaterialCode", argPartnerGoodsMovSerialDetail.ToMaterialCode);


            param[17] = new SqlParameter("@RefDocCode", argPartnerGoodsMovSerialDetail.RefDocCode);
            param[18] = new SqlParameter("@RefDocItemNo", argPartnerGoodsMovSerialDetail.RefDocItemNo);
            param[19] = new SqlParameter("@RefDocType", argPartnerGoodsMovSerialDetail.RefDocType);

            param[20] = new SqlParameter("@TranRefDocCode", argPartnerGoodsMovSerialDetail.TranRefDocCode);
            param[21] = new SqlParameter("@TranRefDocItemNo", argPartnerGoodsMovSerialDetail.TranRefDocItemNo);

            param[22] = new SqlParameter("@ClientCode", argPartnerGoodsMovSerialDetail.ClientCode);
            param[23] = new SqlParameter("@CreatedBy", argPartnerGoodsMovSerialDetail.CreatedBy);
            param[24] = new SqlParameter("@ModifiedBy", argPartnerGoodsMovSerialDetail.ModifiedBy);

            param[25]           = new SqlParameter("@Type", SqlDbType.Char);
            param[25].Size      = 1;
            param[25].Direction = ParameterDirection.Output;

            param[26]           = new SqlParameter("@Message", SqlDbType.VarChar);
            param[26].Size      = 255;
            param[26].Direction = ParameterDirection.Output;

            param[27]           = new SqlParameter("@returnvalue", SqlDbType.VarChar);
            param[27].Size      = 20;
            param[27].Direction = ParameterDirection.Output;


            int i = da.NExecuteNonQuery("Proc_UpdatePartnerGoodsMovSerialDetail", param);


            string strMessage  = Convert.ToString(param[26].Value);
            string strType     = Convert.ToString(param[25].Value);
            string strRetValue = Convert.ToString(param[27].Value);


            objErrorHandler.Type       = strType;
            objErrorHandler.MsgId      = 0;
            objErrorHandler.Module     = ErrorConstant.strInsertModule;
            objErrorHandler.ModulePart = ErrorConstant.strMasterModule;
            objErrorHandler.Message    = strMessage.ToString();
            objErrorHandler.RowNo      = 0;
            objErrorHandler.FieldName  = "";
            objErrorHandler.LogCode    = "";
            lstErr.Add(objErrorHandler);
        }
        public ICollection <ErrorHandler> SavePartnerGoodsMovSerialDetail(PartnerGoodsMovSerialDetail argPartnerGoodsMovSerialDetail)
        {
            List <ErrorHandler> lstErr = new List <ErrorHandler>();
            DataAccess          da     = new DataAccess();

            try
            {
                if (blnIsPartnerGoodsMovSerialDetailExists(argPartnerGoodsMovSerialDetail.PGoodsMovementCode, argPartnerGoodsMovSerialDetail.ItemNo, argPartnerGoodsMovSerialDetail.MaterialCode, argPartnerGoodsMovSerialDetail.SerialNo1, argPartnerGoodsMovSerialDetail.ClientCode) == false)
                {
                    da.Open_Connection();
                    da.BEGIN_TRANSACTION();
                    InsertPartnerGoodsMovSerialDetail(argPartnerGoodsMovSerialDetail, da, lstErr);
                    foreach (ErrorHandler objerr in lstErr)
                    {
                        if (objerr.Type == "E")
                        {
                            da.ROLLBACK_TRANSACTION();
                            return(lstErr);
                        }
                    }
                }
                else
                {
                    da.Open_Connection();
                    da.BEGIN_TRANSACTION();
                    UpdatePartnerGoodsMovSerialDetail(argPartnerGoodsMovSerialDetail, da, lstErr);
                    foreach (ErrorHandler objerr in lstErr)
                    {
                        if (objerr.Type == "E")
                        {
                            da.ROLLBACK_TRANSACTION();
                            return(lstErr);
                        }
                    }
                }
            }
            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);
            }
            finally
            {
                if (da != null)
                {
                    da.Close_Connection();
                    da = null;
                }
            }
            return(lstErr);
        }