public ICollection <Customer_SalesArea> colGetCustomer_SalesArea(DataTable dt, string argUserName, string clientCode)
        {
            List <Customer_SalesArea> lst = new List <Customer_SalesArea>();
            Customer_SalesArea        objCustomer_SalesArea = null;

            foreach (DataRow dr in dt.Rows)
            {
                objCustomer_SalesArea = new Customer_SalesArea();
                objCustomer_SalesArea.CustomerCode          = Convert.ToString(dr["CustomerCode"]).Trim();
                objCustomer_SalesArea.SalesOrganizationCode = Convert.ToString(dr["SalesOrganizationCode"]).Trim();
                objCustomer_SalesArea.DivisionCode          = Convert.ToString(dr["DivisionCode"]).Trim();
                objCustomer_SalesArea.DistChannelCode       = Convert.ToString(dr["DistChannelCode"]).Trim();
                objCustomer_SalesArea.SalesDistrictCode     = Convert.ToString(dr["SalesDistrictCode"]).Trim();
                objCustomer_SalesArea.SalesRegionCode       = Convert.ToString(dr["SalesRegionCode"]).Trim();
                objCustomer_SalesArea.SalesOfficeCode       = Convert.ToString(dr["SalesOfficeCode"]).Trim();
                objCustomer_SalesArea.SalesGroupCode        = Convert.ToString(dr["SalesGroupCode"]).Trim();
                objCustomer_SalesArea.DlvPriorityCode       = Convert.ToString(dr["DlvPriorityCode"]).Trim();
                objCustomer_SalesArea.CurrencyCode          = Convert.ToString(dr["CurrencyCode"]).Trim();
                objCustomer_SalesArea.CustGroupCode         = Convert.ToString(dr["CustGroupCode"]).Trim();
                objCustomer_SalesArea.AccAssignGroupCode    = Convert.ToString(dr["AccAssignGroupCode"]).Trim();
                objCustomer_SalesArea.CrContAreaCode        = Convert.ToString(dr["CrContAreaCode"]).Trim();
                objCustomer_SalesArea.PaymentTermsCode      = Convert.ToString(dr["PaymentTermsCode"]).Trim();
                objCustomer_SalesArea.IncoTermsCode         = Convert.ToString(dr["IncoTermsCode"]).Trim();
                objCustomer_SalesArea.DefaultPlantCode      = Convert.ToString(dr["DefaultPlantCode"]).Trim();
                objCustomer_SalesArea.IsDeleted             = Convert.ToInt32(dr["IsDeleted"]);
                objCustomer_SalesArea.ModifiedBy            = Convert.ToString(argUserName).Trim();
                objCustomer_SalesArea.CreatedBy             = Convert.ToString(argUserName).Trim();
                objCustomer_SalesArea.ClientCode            = Convert.ToString(clientCode).Trim();
                lst.Add(objCustomer_SalesArea);
            }
            return(lst);
        }
        private Customer_SalesArea objCreateCustomer_SalesArea(DataRow dr)
        {
            Customer_SalesArea tCustomer_SalesArea = new Customer_SalesArea();

            tCustomer_SalesArea.SetObjectInfo(dr);
            return(tCustomer_SalesArea);
        }
        public string UpdateCustomer_SalesArea(Customer_SalesArea argCustomer_SalesArea, DataAccess da, List <ErrorHandler> lstErr)
        {
            SqlParameter[] param = new SqlParameter[22];
            param[0]  = new SqlParameter("@CustomerCode", argCustomer_SalesArea.CustomerCode);
            param[1]  = new SqlParameter("@SalesOrganizationCode", argCustomer_SalesArea.SalesOrganizationCode);
            param[2]  = new SqlParameter("@DivisionCode", argCustomer_SalesArea.DivisionCode);
            param[3]  = new SqlParameter("@DistChannelCode", argCustomer_SalesArea.DistChannelCode);
            param[4]  = new SqlParameter("@SalesDistrictCode", argCustomer_SalesArea.SalesDistrictCode);
            param[5]  = new SqlParameter("@SalesRegionCode", argCustomer_SalesArea.SalesRegionCode);
            param[6]  = new SqlParameter("@SalesOfficeCode", argCustomer_SalesArea.SalesOfficeCode);
            param[7]  = new SqlParameter("@SalesGroupCode", argCustomer_SalesArea.SalesGroupCode);
            param[8]  = new SqlParameter("@CustGroupCode", argCustomer_SalesArea.CustGroupCode);
            param[9]  = new SqlParameter("@CurrencyCode", argCustomer_SalesArea.CurrencyCode);
            param[10] = new SqlParameter("@DlvPriorityCode", argCustomer_SalesArea.DlvPriorityCode);
            param[11] = new SqlParameter("@DefaultPlantCode", argCustomer_SalesArea.DefaultPlantCode);
            param[12] = new SqlParameter("@IncoTermsCode", argCustomer_SalesArea.IncoTermsCode);
            param[13] = new SqlParameter("@PaymentTermsCode", argCustomer_SalesArea.PaymentTermsCode);
            param[14] = new SqlParameter("@CrContAreaCode", argCustomer_SalesArea.CrContAreaCode);
            param[15] = new SqlParameter("@AccAssignGroupCode", argCustomer_SalesArea.AccAssignGroupCode);
            param[16] = new SqlParameter("@ClientCode", argCustomer_SalesArea.ClientCode);
            param[17] = new SqlParameter("@CreatedBy", argCustomer_SalesArea.CreatedBy);
            param[18] = new SqlParameter("@ModifiedBy", argCustomer_SalesArea.ModifiedBy);

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

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

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

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

            string strMessage  = Convert.ToString(param[20].Value);
            string strType     = Convert.ToString(param[19].Value);
            string strRetValue = Convert.ToString(param[21].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);

            return(strRetValue);
        }
        public Customer_SalesArea objGetCustomer_SalesArea(string argCustomerCode, string argSalesOrganizationCode, string argDivisionCode, string argDistChannelCode, string argClientCode)
        {
            Customer_SalesArea argCustomer_SalesArea = new Customer_SalesArea();
            DataSet            DataSetToFill         = new DataSet();

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

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

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

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

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

            DataSetToFill = this.GetCustomer_SalesArea(argCustomerCode, argSalesOrganizationCode, argDivisionCode, argDistChannelCode, argClientCode);

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

            argCustomer_SalesArea = this.objCreateCustomer_SalesArea((DataRow)DataSetToFill.Tables[0].Rows[0]);

            goto Finish;

ErrorHandlers:

Finish:
            DataSetToFill = null;


            return(argCustomer_SalesArea);
        }
        public void InsertCustomer_SalesArea(Customer_SalesArea argCustomer_SalesArea, DataAccess da, List <ErrorHandler> lstErr)
        {
            SqlParameter[] param = new SqlParameter[10];
            param[0] = new SqlParameter("@CustomerCode", argCustomer_SalesArea.CustomerCode);
            param[1] = new SqlParameter("@SalesOrganizationCode", argCustomer_SalesArea.SalesOrganizationCode);
            param[2] = new SqlParameter("@DivisionCode", argCustomer_SalesArea.DivisionCode);
            param[3] = new SqlParameter("@DistChannelCode", argCustomer_SalesArea.DistChannelCode);
            param[4] = new SqlParameter("@ClientCode", argCustomer_SalesArea.ClientCode);
            param[5] = new SqlParameter("@CreatedBy", argCustomer_SalesArea.CreatedBy);
            param[6] = new SqlParameter("@ModifiedBy", argCustomer_SalesArea.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_InsertCustomer_SalesArea", 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    = "";
            lstErr.Add(objErrorHandler);
        }
        public ICollection <Customer_SalesArea> colGetCustomer_SalesArea(string argCustomerCode, string argClientCode)
        {
            List <Customer_SalesArea> lst          = new List <Customer_SalesArea>();
            DataSet            DataSetToFill       = new DataSet();
            Customer_SalesArea tCustomer_SalesArea = new Customer_SalesArea();

            DataSetToFill = this.GetCustomer_SalesArea(argCustomerCode, argClientCode);

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

Finish:
            DataSetToFill = null;

            return(lst);
        }
        public ICollection <ErrorHandler> SaveCustomer_SalesArea(Customer_SalesArea argCustomer_SalesArea)
        {
            List <ErrorHandler> lstErr = new List <ErrorHandler>();
            DataAccess          da     = new DataAccess();
            SalesAreaManager    ObjSalesAreaManager = new SalesAreaManager();

            try
            {
                if (ObjSalesAreaManager.blnIsSalesAreaExists(argCustomer_SalesArea.SalesOrganizationCode, argCustomer_SalesArea.DistChannelCode, argCustomer_SalesArea.DivisionCode, argCustomer_SalesArea.ClientCode) == true)
                {
                    if (blnIsCustomer_SalesAreaExists(argCustomer_SalesArea.CustomerCode, argCustomer_SalesArea.SalesOrganizationCode, argCustomer_SalesArea.DivisionCode, argCustomer_SalesArea.DistChannelCode, argCustomer_SalesArea.ClientCode) == false)
                    {
                        da.Open_Connection();
                        da.BEGIN_TRANSACTION();
                        InsertCustomer_SalesArea(argCustomer_SalesArea, 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();
                        UpdateCustomer_SalesArea(argCustomer_SalesArea, da, lstErr);
                        foreach (ErrorHandler objerr in lstErr)
                        {
                            if (objerr.Type == "E")
                            {
                                da.ROLLBACK_TRANSACTION();
                                return(lstErr);
                            }
                        }
                        da.COMMIT_TRANSACTION();
                    }
                }
                else
                {
                    objErrorHandler.Type       = "E";
                    objErrorHandler.MsgId      = 0;
                    objErrorHandler.Module     = ErrorConstant.strInsertModule;
                    objErrorHandler.ModulePart = ErrorConstant.strMasterModule;
                    objErrorHandler.Message    = "Sales Area does not exists.";
                    objErrorHandler.RowNo      = 0;
                    objErrorHandler.FieldName  = "";
                    objErrorHandler.LogCode    = "";
                    lstErr.Add(objErrorHandler);
                }
            }
            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);
        }