private CreditControl_Customer objCreateCreditControl_Customer(DataRow dr)
        {
            CreditControl_Customer tCreditControl_Customer = new CreditControl_Customer();

            tCreditControl_Customer.SetObjectInfo(dr);
            return(tCreditControl_Customer);
        }
        public void UpdateCreditControl_Customer(CreditControl_Customer argCreditControl_Customer, DataAccess da, List <ErrorHandler> lstErr)
        {
            SqlParameter[] param = new SqlParameter[14];
            param[0]  = new SqlParameter("@CrContAreaCode", argCreditControl_Customer.CrContAreaCode);
            param[1]  = new SqlParameter("@CustomerCode", argCreditControl_Customer.CustomerCode);
            param[2]  = new SqlParameter("@SalesOrganizationCode", argCreditControl_Customer.SalesOrganizationCode);
            param[3]  = new SqlParameter("@CurrencyCode", argCreditControl_Customer.CurrencyCode);
            param[4]  = new SqlParameter("@CRUpdateCode", argCreditControl_Customer.CRUpdateCode);
            param[5]  = new SqlParameter("@FiscalYearType", argCreditControl_Customer.FiscalYearType);
            param[6]  = new SqlParameter("@RiskCategoryCode", argCreditControl_Customer.RiskCategoryCode);
            param[7]  = new SqlParameter("@CreditLimit", argCreditControl_Customer.CreditLimit);
            param[8]  = new SqlParameter("@ClientCode", argCreditControl_Customer.ClientCode);
            param[9]  = new SqlParameter("@CreatedBy", argCreditControl_Customer.CreatedBy);
            param[10] = new SqlParameter("@ModifiedBy", argCreditControl_Customer.ModifiedBy);

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

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

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

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

            string strMessage  = Convert.ToString(param[12].Value);
            string strType     = Convert.ToString(param[11].Value);
            string strRetValue = Convert.ToString(param[13].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 CreditControl_Customer objGetCreditControl_Customer(string argCrContAreaCode, string argCustomerCode, string argSalesOrganizationCode, string argClientCode)
        {
            CreditControl_Customer argCreditControl_Customer = new CreditControl_Customer();
            DataSet DataSetToFill = new DataSet();

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

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

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

            if (argClientCode.Trim() == "")
            {
                goto ErrorHandlers;
            }
            DataSetToFill = this.GetCreditControl_Customer(argCrContAreaCode, argCustomerCode, argSalesOrganizationCode, argClientCode);

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

            goto Finish;

ErrorHandlers:

Finish:
            DataSetToFill = null;

            return(argCreditControl_Customer);
        }
        public ICollection <CreditControl_Customer> colGetCreditControl_Customer(DataTable dt, string argUserName, string clientCode)
        {
            List <CreditControl_Customer> lst = new List <CreditControl_Customer>();
            CreditControl_Customer        objCreditControl_Customer = null;

            foreach (DataRow dr in dt.Rows)
            {
                objCreditControl_Customer = new CreditControl_Customer();
                objCreditControl_Customer.CrContAreaCode        = Convert.ToString(dr["CrContAreaCode"]).Trim();
                objCreditControl_Customer.CustomerCode          = Convert.ToString(dr["CustomerCode"]).Trim();
                objCreditControl_Customer.SalesOrganizationCode = Convert.ToString(dr["SalesOrganizationCode"]).Trim();
                objCreditControl_Customer.CurrencyCode          = Convert.ToString(dr["CurrencyCode"]).Trim();
                objCreditControl_Customer.CRUpdateCode          = Convert.ToString(dr["CRUpdateCode"]).Trim();
                objCreditControl_Customer.FiscalYearType        = Convert.ToString(dr["FiscalYearType"]).Trim();
                objCreditControl_Customer.RiskCategoryCode      = Convert.ToString(dr["RiskCategoryCode"]).Trim();
                objCreditControl_Customer.CreditLimit           = Convert.ToInt32(dr["CreditLimit"]);
                objCreditControl_Customer.CreatedBy             = Convert.ToString(argUserName);
                objCreditControl_Customer.ModifiedBy            = Convert.ToString(argUserName);
                objCreditControl_Customer.ClientCode            = Convert.ToString(clientCode).Trim();
                lst.Add(objCreditControl_Customer);
            }
            return(lst);
        }
        public ICollection <ErrorHandler> SaveCreditControl_Customer(CreditControl_Customer argCreditControl_Customer)
        {
            List <ErrorHandler> lstErr = new List <ErrorHandler>();
            DataAccess          da     = new DataAccess();

            try
            {
                if (blnIsCreditControl_CustomerExists(argCreditControl_Customer.CrContAreaCode, argCreditControl_Customer.CustomerCode, argCreditControl_Customer.SalesOrganizationCode, argCreditControl_Customer.ClientCode) == false)
                {
                    da.Open_Connection();
                    da.BEGIN_TRANSACTION();
                    InsertCreditControl_Customer(argCreditControl_Customer, 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();
                    UpdateCreditControl_Customer(argCreditControl_Customer, 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);
        }