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

        public ICollection <ErrorHandler> SaveCustomer_SalesArea(ICollection <Customer_SalesArea> colGetCustomer_SalesArea, DataTable dtCustomer_Tax, DataTable dtCustomer_Partner)
        {
            List <ErrorHandler> lstErr = new List <ErrorHandler>();
            DataAccess          da     = new DataAccess();

            try
            {
                da.Open_Connection();
                da.BEGIN_TRANSACTION();
                string           strretValue         = "";
                SalesAreaManager ObjSalesAreaManager = new SalesAreaManager();

                foreach (Customer_SalesArea argCustomer_SalesArea in colGetCustomer_SalesArea)
                {
                    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, da) == false)
                        {
                            strretValue = InsertCustomer_SalesArea(argCustomer_SalesArea, da, lstErr);
                        }
                        else
                        {
                            strretValue = UpdateCustomer_SalesArea(argCustomer_SalesArea, 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);
                            }
                        }
                    }
                    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);
                    }
                }

                if (strretValue != "")
                {
                    if (dtCustomer_Tax.Rows.Count > 0)
                    {
                        foreach (DataRow dr in dtCustomer_Tax.Rows)
                        {
                            if (Convert.ToInt32(dr["IsDeleted"]) == 0)
                            {
                                Customer_Tax objCustomer_Tax = new Customer_Tax();
                                objCustomer_Tax.CustomerCode    = strretValue.Trim();
                                objCustomer_Tax.CountryCode     = Convert.ToString(dr["CountryCode"]).Trim();
                                objCustomer_Tax.TaxCategoryCode = Convert.ToString(dr["TaxCategoryCode"]).Trim();
                                objCustomer_Tax.TaxClassCode    = Convert.ToString(dr["TaxClassCode"]).Trim();
                                objCustomer_Tax.ClientCode      = Convert.ToString(dr["ClientCode"]).Trim();
                                objCustomer_Tax.CreatedBy       = Convert.ToString(dr["CreatedBy"]).Trim();
                                objCustomer_Tax.ModifiedBy      = Convert.ToString(dr["ModifiedBy"]).Trim();
                                objCustomer_TaxManager.SaveCustomer_Tax(objCustomer_Tax, da, lstErr);
                            }
                            else
                            {
                                objCustomer_TaxManager.DeleteCustomer_Tax(strretValue.ToString().Trim(), Convert.ToString(dr["CountryCode"]).Trim(), Convert.ToString(dr["TaxCategoryCode"]).Trim(), Convert.ToString(dr["TaxClassCode"]).Trim(), Convert.ToString(dr["ClientCode"]).Trim(), 1, da);
                            }
                        }

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

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

                    if (dtCustomer_Partner.Rows.Count > 0)
                    {
                        foreach (DataRow dr in dtCustomer_Partner.Rows)
                        {
                            if (Convert.ToInt32(dr["IsDeleted"]) == 0)
                            {
                                Customer_PartnerFunction objCustomer_Partner = new Customer_PartnerFunction();
                                objCustomer_Partner.CustomerCode          = strretValue.Trim();
                                objCustomer_Partner.SalesOrganizationCode = Convert.ToString(dr["SalesOrganizationCode"]).Trim();
                                objCustomer_Partner.DivisionCode          = Convert.ToString(dr["DivisionCode"]).Trim();
                                objCustomer_Partner.DistChannelCode       = Convert.ToString(dr["DistChannelCode"]).Trim();
                                objCustomer_Partner.PFunctionCode         = Convert.ToString(dr["PFunctionCode"]).Trim();
                                objCustomer_Partner.PartnerCounter        = Convert.ToInt32(dr["PartnerCounter"]);
                                objCustomer_Partner.PartnerTable          = Convert.ToString(dr["PartnerTable"]).Trim();
                                objCustomer_Partner.PartnerCode           = Convert.ToString(dr["PartnerCode"]).Trim();
                                objCustomer_Partner.ClientCode            = Convert.ToString(dr["ClientCode"]).Trim();
                                objCustomer_Partner.CreatedBy             = Convert.ToString(dr["CreatedBy"]).Trim();
                                objCustomer_Partner.ModifiedBy            = Convert.ToString(dr["ModifiedBy"]).Trim();
                                objCustomer_PartnerFunctionManager.SaveCustomer_PartnerFunction(objCustomer_Partner, da, lstErr);
                            }
                            else
                            {
                                objCustomer_PartnerFunctionManager.DeleteCustomer_PartnerFunction(strretValue.ToString().Trim(), Convert.ToString(dr["PFunctionCode"]).Trim(), Convert.ToString(dr["ClientCode"]).Trim(), 1, da);
                            }
                        }

                        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);
        }
Esempio n. 3
0
        public bool blnCheckBasicRules(SalesOrder argSalesOrder, List <ErrorHandler> lstErr)
        {
            bool             retValue            = true;
            SalesAreaManager objSalesAreaManager = new SalesAreaManager();

            if (objSalesAreaManager.blnIsSalesAreaExists(argSalesOrder.SalesOrganizationCode, argSalesOrder.DistChannelCode, argSalesOrder.DivisionCode, argSalesOrder.ClientCode) == false)
            {
                objErrorHandler.Type        = ErrorConstant.strErrType;
                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     = "";
                objErrorHandler.ReturnValue = "";
                lstErr.Add(objErrorHandler);

                retValue            = false;
                objSalesAreaManager = null;
            }

            Customer_SalesAreaManager objCustSalesArea = new Customer_SalesAreaManager();

            if (objCustSalesArea.blnIsCustomer_SalesAreaExists(argSalesOrder.CustomerCode, argSalesOrder.SalesOrganizationCode, argSalesOrder.DivisionCode, argSalesOrder.DistChannelCode, argSalesOrder.ClientCode) == false)
            {
                objErrorHandler.Type        = ErrorConstant.strErrType;
                objErrorHandler.MsgId       = 0;
                objErrorHandler.Module      = ErrorConstant.strInsertModule;
                objErrorHandler.ModulePart  = ErrorConstant.strMasterModule;
                objErrorHandler.Message     = "Map Customer to Sales Area.";
                objErrorHandler.RowNo       = 0;
                objErrorHandler.FieldName   = "";
                objErrorHandler.LogCode     = "";
                objErrorHandler.ReturnValue = "";
                lstErr.Add(objErrorHandler);


                retValue         = false;
                objCustSalesArea = null;
            }

            //SalesArea_SalesOfficeManager objSalesAreaoffice = new SalesArea_SalesOfficeManager();
            //if (objSalesAreaoffice.blnIsSalesArea_SalesOfficeExists(argSalesOrder.SalesOrganizationCode, argSalesOrder.DistChannelCode, argSalesOrder.DivisionCode, argSalesOrder.SalesofficeCode, argSalesOrder.ClientCode) == false)
            //{
            //    objErrorHandler.Type = ErrorConstant.strErrType;
            //    objErrorHandler.MsgId = 0;
            //    objErrorHandler.Module = ErrorConstant.strInsertModule;
            //    objErrorHandler.ModulePart = ErrorConstant.strMasterModule;
            //    objErrorHandler.Message = "Map Sales Office to Sales Area.";
            //    objErrorHandler.RowNo = 0;
            //    objErrorHandler.FieldName = "";
            //    objErrorHandler.LogCode = "";
            //    objErrorHandler.ReturnValue = "";
            //    lstErr.Add(objErrorHandler);


            //    retValue = false;
            //    objSalesAreaoffice = null;
            //}

            //SalesOffice_SalesGroupManager objSalesOfficeGroup = new SalesOffice_SalesGroupManager();
            //if (objSalesOfficeGroup.blnIsSalesOffice_SalesGroupExists(argSalesOrder.SalesGroupCode, argSalesOrder.SalesofficeCode, argSalesOrder.ClientCode) == false)
            //{
            //    objErrorHandler.Type = ErrorConstant.strErrType;
            //    objErrorHandler.MsgId = 0;
            //    objErrorHandler.Module = ErrorConstant.strInsertModule;
            //    objErrorHandler.ModulePart = ErrorConstant.strMasterModule;
            //    objErrorHandler.Message = "Map Sales Office to Sales Group.";
            //    objErrorHandler.RowNo = 0;
            //    objErrorHandler.FieldName = "";
            //    objErrorHandler.LogCode = "";
            //    objErrorHandler.ReturnValue = "";
            //    lstErr.Add(objErrorHandler);


            //    retValue = false;
            //    objSalesOfficeGroup = null;
            //}


            return(retValue);
        }
        public ICollection <ErrorHandler> SaveSOType_SalesArea(ICollection <SOType_SalesArea> colGetSOType_SalesArea, List <ErrorHandler> lstErr)
        {
            DataAccess       da = new DataAccess();
            SalesAreaManager ObjSalesAreaManager = new SalesAreaManager();

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

                foreach (SOType_SalesArea argSOType_SalesArea in colGetSOType_SalesArea)
                {
                    if (argSOType_SalesArea.IsDeleted == 0)
                    {
                        if (ObjSalesAreaManager.blnIsSalesAreaExists(argSOType_SalesArea.SalesOrganizationCode, argSOType_SalesArea.DistChannelCode, argSOType_SalesArea.DivisionCode, argSOType_SalesArea.ClientCode) == true)
                        {
                            if (blnIsSOType_SalesAreaExists(argSOType_SalesArea.SalesOrganizationCode, argSOType_SalesArea.DistChannelCode, argSOType_SalesArea.DivisionCode, argSOType_SalesArea.SOTypeCode, argSOType_SalesArea.ClientCode, da) == false)
                            {
                                InsertSOType_SalesArea(argSOType_SalesArea, da, lstErr);
                            }
                            else
                            {
                                UpdateSOType_SalesArea(argSOType_SalesArea, da, lstErr);
                            }
                        }
                    }
                    else
                    {
                        DeleteSOType_SalesArea(argSOType_SalesArea.SalesOrganizationCode, argSOType_SalesArea.DistChannelCode, argSOType_SalesArea.DivisionCode, argSOType_SalesArea.SOTypeCode, argSOType_SalesArea.ClientCode);
                    }
                }

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