private Partner_MaterialGroup objCreatePartner_MaterialGroup(DataRow dr)
        {
            Partner_MaterialGroup tPartner_MaterialGroup = new Partner_MaterialGroup();

            tPartner_MaterialGroup.SetObjectInfo(dr);
            return(tPartner_MaterialGroup);
        }
        public ICollection <Partner_MaterialGroup> colGetPartner_MaterialGroup(DataTable dt, string argUserName, string clientCode)
        {
            List <Partner_MaterialGroup> lst = new List <Partner_MaterialGroup>();
            Partner_MaterialGroup        objPartner_MaterialGroup = null;

            foreach (DataRow dr in dt.Rows)
            {
                objPartner_MaterialGroup = new Partner_MaterialGroup();
                objPartner_MaterialGroup.PartnerTypeCode = Convert.ToString(dr["PartnerTypeCode"]).Trim();
                objPartner_MaterialGroup.MatGroup1Code   = Convert.ToString(dr["MatGroup1Code"]).Trim();
                objPartner_MaterialGroup.IsAllowed       = Convert.ToInt32(dr["IsAllowed"]);
                objPartner_MaterialGroup.IsDeleted       = Convert.ToInt32(dr["IsDeleted"]);
                objPartner_MaterialGroup.ModifiedBy      = Convert.ToString(argUserName).Trim();
                objPartner_MaterialGroup.CreatedBy       = Convert.ToString(argUserName).Trim();
                objPartner_MaterialGroup.ClientCode      = Convert.ToString(clientCode).Trim();
                lst.Add(objPartner_MaterialGroup);
            }
            return(lst);
        }
        public void UpdatePartner_MaterialGroup(Partner_MaterialGroup argPartner_MaterialGroup, DataAccess da, List <ErrorHandler> lstErr)
        {
            SqlParameter[] param = new SqlParameter[9];
            param[0] = new SqlParameter("@PartnerTypeCode", argPartner_MaterialGroup.PartnerTypeCode);
            param[1] = new SqlParameter("@MatGroup1Code", argPartner_MaterialGroup.MatGroup1Code);
            param[2] = new SqlParameter("@IsAllowed", argPartner_MaterialGroup.IsAllowed);
            param[3] = new SqlParameter("@ClientCode", argPartner_MaterialGroup.ClientCode);
            param[4] = new SqlParameter("@CreatedBy", argPartner_MaterialGroup.CreatedBy);
            param[5] = new SqlParameter("@ModifiedBy", argPartner_MaterialGroup.ModifiedBy);

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

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

            param[8]           = new SqlParameter("@returnvalue", SqlDbType.VarChar);
            param[8].Size      = 20;
            param[8].Direction = ParameterDirection.Output;
            int i = da.NExecuteNonQuery("Proc_UpdatePartner_MaterialGroup", param);


            string strMessage  = Convert.ToString(param[7].Value);
            string strType     = Convert.ToString(param[6].Value);
            string strRetValue = Convert.ToString(param[8].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 Partner_MaterialGroup objGetPartner_MaterialGroup(string argPartnerCode, string argMatGroup1Code, string argClientCode)
        {
            Partner_MaterialGroup argPartner_MaterialGroup = new Partner_MaterialGroup();
            DataSet DataSetToFill = new DataSet();

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

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

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

            DataSetToFill = this.GetPartner_MaterialGroup(argPartnerCode, argMatGroup1Code, argClientCode);

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

            argPartner_MaterialGroup = this.objCreatePartner_MaterialGroup((DataRow)DataSetToFill.Tables[0].Rows[0]);

            goto Finish;

ErrorHandlers:

Finish:
            DataSetToFill = null;


            return(argPartner_MaterialGroup);
        }
        public ICollection <Partner_MaterialGroup> colGetPartner_MaterialGroup(string argPartnerCode, string argClientCode)
        {
            List <Partner_MaterialGroup> lst             = new List <Partner_MaterialGroup>();
            DataSet DataSetToFill                        = new DataSet();
            Partner_MaterialGroup tPartner_MaterialGroup = new Partner_MaterialGroup();

            DataSetToFill = this.GetPartner_MaterialGroup(argPartnerCode, argClientCode);

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

Finish:
            DataSetToFill = null;


            return(lst);
        }
        public ICollection <ErrorHandler> SavePartner_MaterialGroup(Partner_MaterialGroup argPartner_MaterialGroup)
        {
            List <ErrorHandler> lstErr = new List <ErrorHandler>();
            DataAccess          da     = new DataAccess();

            try
            {
                if (blnIsPartner_MaterialGroupExists(argPartner_MaterialGroup.PartnerTypeCode, argPartner_MaterialGroup.MatGroup1Code, argPartner_MaterialGroup.ClientCode) == false)
                {
                    da.Open_Connection();
                    da.BEGIN_TRANSACTION();
                    InsertPartner_MaterialGroup(argPartner_MaterialGroup, 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();
                    UpdatePartner_MaterialGroup(argPartner_MaterialGroup, 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);
        }