public void SaveSalesOrderPartner(SalesOrderPartner argSalesOrderPartner, DataAccess da, List <ErrorHandler> lstErr)
 {
     try
     {
         if (blnIsSalesOrderPartnerExists(argSalesOrderPartner.SODocmentCode, argSalesOrderPartner.PFunctionCode, argSalesOrderPartner.ClientCode, da) == false)
         {
             InsertSalesOrderPartner(argSalesOrderPartner, da, lstErr);
         }
         else
         {
             UpdateSalesOrderPartner(argSalesOrderPartner, 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 SalesOrderPartner objCreateSalesOrderPartner(DataRow dr)
        {
            SalesOrderPartner tSalesOrderPartner = new SalesOrderPartner();

            tSalesOrderPartner.SetObjectInfo(dr);

            return(tSalesOrderPartner);
        }
        //public ICollection<ErrorHandler> SaveSalesOrderPartner(SalesOrderPartner argSalesOrderPartner)
        //{
        //    List<ErrorHandler> lstErr = new List<ErrorHandler>();
        //    DataAccess da = new DataAccess();
        //    try
        //    {
        //        if (blnIsSalesOrderPartnerExists(argSalesOrderPartner.SODocmentCode, argSalesOrderPartner.ClientCode) == false)
        //        {

        //            da.Open_Connection();
        //            da.BEGIN_TRANSACTION();
        //            InsertSalesOrderPartner(argSalesOrderPartner, da, lstErr);
        //            foreach (ErrorHandler objerr in lstErr)
        //            {
        //                if (objerr.Type == "E")
        //                {
        //                    da.ROLLBACK_TRANSACTION();
        //                    return lstErr;
        //                }
        //            }
        //            da.COMMIT_TRANSACTION();
        //        }
        //        else
        //        {
        //            da.Open_Connection();
        //            da.BEGIN_TRANSACTION();
        //            UpdateSalesOrderPartner(argSalesOrderPartner, da, lstErr);
        //            foreach (ErrorHandler objerr in lstErr)
        //            {
        //                if (objerr.Type == "E")
        //                {
        //                    da.ROLLBACK_TRANSACTION();
        //                    return lstErr;
        //                }
        //            }
        //            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);
        //    }
        //    finally
        //    {
        //        if (da != null)
        //        {
        //            da.Close_Connection();
        //            da = null;
        //        }
        //    }
        //    return lstErr;
        //}

        public void InsertSalesOrderPartner(SalesOrderPartner argSalesOrderPartner, DataAccess da, List <ErrorHandler> lstErr)
        {
            SqlParameter[] param = new SqlParameter[10];
            param[0] = new SqlParameter("@SODocmentCode", argSalesOrderPartner.SODocmentCode);
            param[1] = new SqlParameter("@PFunctionCode", argSalesOrderPartner.PFunctionCode);
            param[2] = new SqlParameter("@PartnerType", argSalesOrderPartner.PartnerType);
            param[3] = new SqlParameter("@CustomerCode", argSalesOrderPartner.CustomerCode);
            param[4] = new SqlParameter("@ClientCode", argSalesOrderPartner.ClientCode);
            param[5] = new SqlParameter("@CreatedBy", argSalesOrderPartner.CreatedBy);
            param[6] = new SqlParameter("@ModifiedBy", argSalesOrderPartner.ModifiedBy);

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

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

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

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


            string strMessage  = Convert.ToString(param[8].Value);
            string strType     = Convert.ToString(param[7].Value);
            string strRetValue = Convert.ToString(param[9].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     = "";
            objErrorHandler.ReturnValue = strRetValue;
            lstErr.Add(objErrorHandler);
        }
        public SalesOrderPartner objGetSalesOrderPartner(string argSODocmentCode, string argPFunctionCode, string argClientCode)
        {
            SalesOrderPartner argSalesOrderPartner = new SalesOrderPartner();
            DataSet           DataSetToFill        = new DataSet();

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

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


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

            DataSetToFill = this.GetSalesOrderPartner(argSODocmentCode, argClientCode, argPFunctionCode);

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

            argSalesOrderPartner = this.objCreateSalesOrderPartner((DataRow)DataSetToFill.Tables[0].Rows[0]);

            goto Finish;

ErrorHandlers:

Finish:
            DataSetToFill = null;


            return(argSalesOrderPartner);
        }
        public ICollection <SalesOrderPartner> colGetSalesOrderPartner(string argSODocmentCode, string argClientCode)
        {
            List <SalesOrderPartner> lst         = new List <SalesOrderPartner>();
            DataSet           DataSetToFill      = new DataSet();
            SalesOrderPartner tSalesOrderPartner = new SalesOrderPartner();

            DataSetToFill = this.GetSalesOrderPartner(argSODocmentCode, argClientCode);

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

Finish:
            DataSetToFill = null;


            return(lst);
        }
Exemple #6
0
        public ICollection <ErrorHandler> SaveSalesOrder(SalesOrder argSalesOrder, ICollection <SalesOrderDetail> colSalesOrderDetail, ICollection <SOPriceCondition> colSOPriceCondition, ICollection <SOSchedule> colSOSchedule, ICollection <CharactersticsValueMaster> colCharactersticsValueMaster, DataTable dtOrderPartner)
        {
            List <ErrorHandler> lstErr = new List <ErrorHandler>();
            DataAccess          da     = new DataAccess();

            string strretValue = "";

            try
            {
                // if (blnCheckBasicRules(argSalesOrder, lstErr) == true)
                // {

                da.Open_Connection();
                da.BEGIN_TRANSACTION();

                if (blnIsSalesOrderExists(argSalesOrder.SODocCode, argSalesOrder.ClientCode, da) == false)
                {
                    strretValue = InsertSalesOrder(argSalesOrder, da, lstErr);
                }
                else
                {
                    strretValue = UpdateSalesOrder(argSalesOrder, da, lstErr);
                }

                foreach (ErrorHandler objerr in lstErr)
                {
                    if (objerr.Type == "E")
                    {
                        da.ROLLBACK_TRANSACTION();
                        return(lstErr);
                    }

                    if (objerr.Type == "A")
                    {
                        da.ROLLBACK_TRANSACTION();
                        return(lstErr);
                    }
                }

                if (strretValue != "")
                {
                    if (colSalesOrderDetail.Count > 0)
                    {
                        foreach (SalesOrderDetail argSalesOrderDetail in colSalesOrderDetail)
                        {
                            argSalesOrderDetail.SODocCode = Convert.ToString(strretValue);

                            if (argSalesOrderDetail.ErrFlag == 0)
                            {
                                if (argSalesOrderDetail.IsDeleted == 0)
                                {
                                    objSalesOrderDetailManager.SaveSalesOrderDetail(argSalesOrderDetail, da, lstErr);
                                }
                                else
                                {
                                    objSalesOrderDetailManager.DeleteSalesOrderDetail(argSalesOrderDetail.SODocCode, argSalesOrderDetail.ItemNo, argSalesOrderDetail.ClientCode, da, lstErr);
                                }

                                if (colSOPriceCondition.Count > 0)
                                {
                                    foreach (SOPriceCondition argSOPriceCon in colSOPriceCondition)
                                    {
                                        if (argSOPriceCon.ItemNo == argSalesOrderDetail.ItemNo)
                                        {
                                            argSOPriceCon.SODocCode = Convert.ToString(strretValue);

                                            if (argSOPriceCon.IsDeleted == 0)
                                            {
                                                objSOPriceConditionManager.SaveSOPriceCondition(argSOPriceCon, da, lstErr);
                                            }
                                            else
                                            {
                                                objSOPriceConditionManager.DeleteSOPriceCondition(argSOPriceCon.SODocCode, argSOPriceCon.ItemNo, argSOPriceCon.ConditionType, argSOPriceCon.ClientCode, argSOPriceCon.IsDeleted);
                                            }
                                        }
                                    }
                                }

                                if (colSOSchedule.Count > 0)
                                {
                                    foreach (SOSchedule argSOSchedule in colSOSchedule)
                                    {
                                        if (argSOSchedule.ItemNo == argSalesOrderDetail.ItemNo)
                                        {
                                            argSOSchedule.SODocCode = Convert.ToString(strretValue);

                                            if (argSOSchedule.IsDeleted == 0)
                                            {
                                                objSalesOrderScheduleManager.SaveSOSchedule(argSOSchedule, da, lstErr);
                                            }
                                            //else
                                            //{
                                            //    objSOPriceConditionManager.DeleteSOPriceCondition(argSOPriceCon.SODocCode, argSOPriceCon.ItemNo, argSOPriceCon.ConditionType, argSOPriceCon.ClientCode, argSOPriceCon.IsDeleted);
                                            //}
                                        }
                                    }
                                }
                            }
                        }

                        foreach (ErrorHandler objerr in lstErr)
                        {
                            if (objerr.Type == "E")
                            {
                                da.ROLLBACK_TRANSACTION();
                                return(lstErr);
                            }

                            if (objerr.Type == "A")
                            {
                                da.ROLLBACK_TRANSACTION();
                                return(lstErr);
                            }
                        }
                    }

                    if (colCharactersticsValueMaster.Count > 0)
                    {
                        foreach (CharactersticsValueMaster argCharactersticsValueMaster in colCharactersticsValueMaster)
                        {
                            if (argCharactersticsValueMaster.ObjectKey.Contains("NEW") == true)
                            {
                                argCharactersticsValueMaster.ObjectKey = Convert.ToString(strretValue).Trim() + argCharactersticsValueMaster.ObjectKey.Substring(3).Trim();
                                argCharactersticsValueMaster.ObjectKey = argCharactersticsValueMaster.ObjectKey.Trim();
                            }

                            objCharValueMasterManager.SaveCharactersticsValueMaster(argCharactersticsValueMaster, da, lstErr);
                        }

                        foreach (ErrorHandler objerr in lstErr)
                        {
                            if (objerr.Type == "E")
                            {
                                da.ROLLBACK_TRANSACTION();
                                return(lstErr);
                            }

                            if (objerr.Type == "A")
                            {
                                da.ROLLBACK_TRANSACTION();
                                return(lstErr);
                            }
                        }
                    }


                    foreach (DataRow dr in dtOrderPartner.Rows)
                    {
                        SalesOrderPartner objSalesOrderPartner = new SalesOrderPartner();

                        objSalesOrderPartner.SODocmentCode = strretValue;
                        objSalesOrderPartner.PFunctionCode = Convert.ToString(dr["PFunctionCode"]).Trim();
                        objSalesOrderPartner.CustomerCode  = Convert.ToString(dr["CustomerCode"]).Trim();
                        objSalesOrderPartner.PartnerType   = Convert.ToString(dr["PartnerType"]).Trim();
                        objSalesOrderPartner.ClientCode    = Convert.ToString(dr["ClientCode"]).Trim();
                        objSalesOrderPartner.CreatedBy     = Convert.ToString(dr["CreatedBy"]).Trim();
                        objSalesOrderPartner.ModifiedBy    = Convert.ToString(dr["ModifiedBy"]).Trim();

                        objOrderPartnerManager.SaveSalesOrderPartner(objSalesOrderPartner, da, lstErr);
                    }

                    foreach (ErrorHandler objerr in lstErr)
                    {
                        if (objerr.Type == "E")
                        {
                            da.ROLLBACK_TRANSACTION();
                            return(lstErr);
                        }

                        if (objerr.Type == "A")
                        {
                            da.ROLLBACK_TRANSACTION();
                            return(lstErr);
                        }
                    }
                }



                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);
            }
            finally
            {
                if (da != null)
                {
                    da.Close_Connection();
                    da = null;
                }
            }
            return(lstErr);
        }