private SalesOffice_SalesGroup objCreateSalesOffice_SalesGroup(DataRow dr)
        {
            SalesOffice_SalesGroup tSalesOffice_SalesGroup = new SalesOffice_SalesGroup();

            tSalesOffice_SalesGroup.SetObjectInfo(dr);

            return(tSalesOffice_SalesGroup);
        }
        public ICollection <SalesOffice_SalesGroup> colGetSalesOffice_SalesGroup(DataTable dt, string argUserName, string clientCode)
        {
            List <SalesOffice_SalesGroup> lst = new List <SalesOffice_SalesGroup>();
            SalesOffice_SalesGroup        objSalesOffice_SalesGroup = null;

            foreach (DataRow dr in dt.Rows)
            {
                objSalesOffice_SalesGroup = new SalesOffice_SalesGroup();
                objSalesOffice_SalesGroup.SalesGroupCode  = Convert.ToString(dr["SalesGroupCode"]).Trim();
                objSalesOffice_SalesGroup.SalesofficeCode = Convert.ToString(dr["SalesofficeCode"]).Trim();
                objSalesOffice_SalesGroup.CreatedBy       = Convert.ToString(argUserName);
                objSalesOffice_SalesGroup.ModifiedBy      = Convert.ToString(argUserName);
                objSalesOffice_SalesGroup.ClientCode      = Convert.ToString(clientCode).Trim();
                lst.Add(objSalesOffice_SalesGroup);
            }
            return(lst);
        }
        /**********/

        public void InsertSalesOffice_SalesGroup(SalesOffice_SalesGroup argSalesOffice_SalesGroup, DataAccess da, List <ErrorHandler> lstErr)
        {
            SqlParameter[] param = new SqlParameter[8];
            param[0] = new SqlParameter("@SalesGroupCode", argSalesOffice_SalesGroup.SalesGroupCode);
            param[1] = new SqlParameter("@SalesofficeCode", argSalesOffice_SalesGroup.SalesofficeCode);
            param[2] = new SqlParameter("@ClientCode", argSalesOffice_SalesGroup.ClientCode);
            param[3] = new SqlParameter("@CreatedBy", argSalesOffice_SalesGroup.CreatedBy);
            param[4] = new SqlParameter("@ModifiedBy", argSalesOffice_SalesGroup.ModifiedBy);

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

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

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

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


            string strMessage  = Convert.ToString(param[6].Value);
            string strType     = Convert.ToString(param[5].Value);
            string strRetValue = Convert.ToString(param[7].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 SalesOffice_SalesGroup objGetSalesOffice_SalesGroup(string argSalesGroupCode, string argSalesofficeCode, string argClientCode)
        {
            SalesOffice_SalesGroup argSalesOffice_SalesGroup = new SalesOffice_SalesGroup();
            DataSet DataSetToFill = new DataSet();

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

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

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

            DataSetToFill = this.GetSalesOffice_SalesGroup(argSalesGroupCode, argSalesofficeCode, argClientCode);

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

            argSalesOffice_SalesGroup = this.objCreateSalesOffice_SalesGroup((DataRow)DataSetToFill.Tables[0].Rows[0]);

            goto Finish;

ErrorHandlers:

Finish:
            DataSetToFill = null;


            return(argSalesOffice_SalesGroup);
        }
        public ICollection <ErrorHandler> SaveSalesOffice_SalesGroup(SalesOffice_SalesGroup argSalesOffice_SalesGroup)
        {
            List <ErrorHandler> lstErr = new List <ErrorHandler>();
            DataAccess          da     = new DataAccess();

            try
            {
                if (blnIsSalesOffice_SalesGroupExists(argSalesOffice_SalesGroup.SalesGroupCode, argSalesOffice_SalesGroup.SalesofficeCode, argSalesOffice_SalesGroup.ClientCode) == false)
                {
                    da.Open_Connection();
                    da.BEGIN_TRANSACTION();
                    InsertSalesOffice_SalesGroup(argSalesOffice_SalesGroup, 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();
                    UpdateSalesOffice_SalesGroup(argSalesOffice_SalesGroup, 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);
        }