예제 #1
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(LPWeb.Model.Branches model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into Branches(");
            strSql.Append("Name,[Desc],Enabled,RegionID,DivisionID,GroupID,BranchAddress,City,BranchState,Zip,WebsiteLogo,Phone,Fax,Email,WebURL)");
            strSql.Append(" values (");
            strSql.Append("@Name,@Desc,@Enabled,@RegionID,@DivisionID,@GroupID,@BranchAddress,@City,@BranchState,@Zip,@WebsiteLogo,@Phone,@Fax,@Email,@WebURL)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@Name",          SqlDbType.NVarChar,    50),
                new SqlParameter("@Desc",          SqlDbType.NVarChar,   500),
                new SqlParameter("@Enabled",       SqlDbType.Bit,          1),
                new SqlParameter("@RegionID",      SqlDbType.Int,          4),
                new SqlParameter("@DivisionID",    SqlDbType.Int,          4),
                new SqlParameter("@GroupID",       SqlDbType.Int,          4),
                new SqlParameter("@BranchAddress", SqlDbType.NVarChar,   255),
                new SqlParameter("@City",          SqlDbType.NVarChar,    50),
                new SqlParameter("@BranchState",   SqlDbType.NVarChar,     2),
                new SqlParameter("@Zip",           SqlDbType.NVarChar,     5),
                new SqlParameter("@WebsiteLogo",   SqlDbType.VarBinary),
                new SqlParameter("@Phone",         SqlDbType.NVarChar,    20),
                new SqlParameter("@Fax",           SqlDbType.NVarChar,    20),
                new SqlParameter("@Email",         SqlDbType.NVarChar,   255),
                new SqlParameter("@WebURL",        SqlDbType.NVarChar, 255)
            };

            parameters[0].Value  = model.Name;
            parameters[1].Value  = model.Desc;
            parameters[2].Value  = model.Enabled;
            parameters[3].Value  = model.RegionID;
            parameters[4].Value  = model.DivisionID;
            parameters[5].Value  = model.GroupID;
            parameters[6].Value  = model.BranchAddress;
            parameters[7].Value  = model.City;
            parameters[8].Value  = model.BranchState;
            parameters[9].Value  = model.Zip;
            parameters[10].Value = model.WebsiteLogo;
            parameters[11].Value = model.Phone;
            parameters[12].Value = model.Fax;
            parameters[13].Value = model.Email;
            parameters[14].Value = model.WebURL;


            object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters);

            if (obj == null)
            {
                return(1);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
예제 #2
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                LPWeb.Model.Branches model = new LPWeb.Model.Branches();
                model.BranchId        = BranchID;
                model.EnableMailChimp = cbEnableMailChimp.Checked;
                model.MailChimpAPIKey = txbMCKey.Text.Trim();

                bllB.UpdateChimpAPIKey(model);
            }
            catch
            {
            }
        }
예제 #3
0
        private void FillControl()
        {
            LPWeb.Model.Branches model = new LPWeb.Model.Branches();
            model = bllB.GetModel(BranchID);

            cbEnableMailChimp.Checked = model.EnableMailChimp;

            txbMCKey.Text = model.MailChimpAPIKey;

            if (cbEnableMailChimp.Checked)
            {
                txbMCKey.Enabled = true;
            }
            else
            {
                txbMCKey.Enabled = false;
            }
        }
예제 #4
0
        /// <summary>
        /// UpdateChimpAPIKey
        /// </summary>
        public void UpdateChimpAPIKey(LPWeb.Model.Branches model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append(" update Branches set ");
            strSql.Append(" EnableMailChimp=@EnableMailChimp,");
            strSql.Append(" MailChimpAPIKey=@MailChimpAPIKey ");
            strSql.Append(" where BranchId=@BranchId ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@BranchId",        SqlDbType.Int,      4),
                new SqlParameter("@EnableMailChimp", SqlDbType.Bit),
                new SqlParameter("@MailChimpAPIKey", SqlDbType.NVarChar, 255)
            };

            parameters[0].Value = model.BranchId;
            parameters[1].Value = model.EnableMailChimp;
            parameters[2].Value = model.MailChimpAPIKey;

            DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);
        }
예제 #5
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public void Update(LPWeb.Model.Branches model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update Branches set ");
            strSql.Append("BranchId=@BranchId,");
            strSql.Append("Name=@Name,");
            strSql.Append("[Desc]=@Desc,");
            strSql.Append("Enabled=@Enabled,");
            strSql.Append("RegionID=@RegionID,");
            strSql.Append("DivisionID=@DivisionID,");
            strSql.Append("GroupID=@GroupID,");
            strSql.Append("BranchAddress=@BranchAddress,");
            strSql.Append("City=@City,");
            strSql.Append("BranchState=@BranchState,");
            strSql.Append("Zip=@Zip,");
            strSql.Append("WebsiteLogo=@WebsiteLogo,");
            strSql.Append("Phone=@Phone,");
            strSql.Append("Fax=@Fax,");
            strSql.Append("Email=@Email,");
            strSql.Append("WebURL=@WebURL,");
            strSql.Append(" where BranchId=@BranchId ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@BranchId",      SqlDbType.Int,          4),
                new SqlParameter("@Name",          SqlDbType.NVarChar,    50),
                new SqlParameter("@Desc",          SqlDbType.NVarChar,   500),
                new SqlParameter("@Enabled",       SqlDbType.Bit,          1),
                new SqlParameter("@RegionID",      SqlDbType.Int,          4),
                new SqlParameter("@DivisionID",    SqlDbType.Int,          4),
                new SqlParameter("@GroupID",       SqlDbType.Int,          4),
                new SqlParameter("@BranchAddress", SqlDbType.NVarChar,   255),
                new SqlParameter("@City",          SqlDbType.NVarChar,    50),
                new SqlParameter("@BranchState",   SqlDbType.NVarChar,     2),
                new SqlParameter("@Zip",           SqlDbType.NVarChar,     5),
                new SqlParameter("@WebsiteLogo",   SqlDbType.VarBinary),
                new SqlParameter("@Phone",         SqlDbType.NVarChar,    20),
                new SqlParameter("@Fax",           SqlDbType.NVarChar,    20),
                new SqlParameter("@Email",         SqlDbType.NVarChar,   255),
                new SqlParameter("@WebURL",        SqlDbType.NVarChar, 255)
            };

            parameters[0].Value  = model.BranchId;
            parameters[1].Value  = model.Name;
            parameters[2].Value  = model.Desc;
            parameters[3].Value  = model.Enabled;
            parameters[4].Value  = model.RegionID;
            parameters[5].Value  = model.DivisionID;
            parameters[6].Value  = model.GroupID;
            parameters[7].Value  = model.BranchAddress;
            parameters[8].Value  = model.City;
            parameters[9].Value  = model.BranchState;
            parameters[10].Value = model.Zip;
            parameters[11].Value = model.WebsiteLogo;
            parameters[12].Value = model.Phone;
            parameters[13].Value = model.Fax;
            parameters[14].Value = model.Email;
            parameters[15].Value = model.WebURL;



            DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);
        }
예제 #6
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>

        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public LPWeb.Model.Branches GetModel(int BranchId)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 BranchId,[Name],[Desc],Enabled,RegionID,DivisionID,GroupID,BranchAddress,City,BranchState,Zip,WebsiteLogo,GlobalId,License1,License2,License3,License4,Disclaimer,Phone,Fax,WebURL,Email,License5,Leadstar_Username,Leadstar_ID,Leadstar_Userid,HomeBranch,EnableMailChimp,MailChimpAPIKey from Branches ");
            strSql.Append(" where BranchId=@BranchId");
            SqlParameter[] parameters =
            {
                new SqlParameter("@BranchId", SqlDbType.Int, 4)
            };
            parameters[0].Value = BranchId;

            LPWeb.Model.Branches model = new LPWeb.Model.Branches();
            DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["BranchId"] != null && ds.Tables[0].Rows[0]["BranchId"].ToString() != "")
                {
                    model.BranchId = int.Parse(ds.Tables[0].Rows[0]["BranchId"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Name"] != null && ds.Tables[0].Rows[0]["Name"].ToString() != "")
                {
                    model.Name = ds.Tables[0].Rows[0]["Name"].ToString();
                }
                if (ds.Tables[0].Rows[0]["Desc"] != null && ds.Tables[0].Rows[0]["Desc"].ToString() != "")
                {
                    model.Desc = ds.Tables[0].Rows[0]["Desc"].ToString();
                }
                if (ds.Tables[0].Rows[0]["Enabled"] != null && ds.Tables[0].Rows[0]["Enabled"].ToString() != "")
                {
                    if ((ds.Tables[0].Rows[0]["Enabled"].ToString() == "1") || (ds.Tables[0].Rows[0]["Enabled"].ToString().ToLower() == "true"))
                    {
                        model.Enabled = true;
                    }
                    else
                    {
                        model.Enabled = false;
                    }
                }
                if (ds.Tables[0].Rows[0]["RegionID"] != null && ds.Tables[0].Rows[0]["RegionID"].ToString() != "")
                {
                    model.RegionID = int.Parse(ds.Tables[0].Rows[0]["RegionID"].ToString());
                }
                if (ds.Tables[0].Rows[0]["DivisionID"] != null && ds.Tables[0].Rows[0]["DivisionID"].ToString() != "")
                {
                    model.DivisionID = int.Parse(ds.Tables[0].Rows[0]["DivisionID"].ToString());
                }
                if (ds.Tables[0].Rows[0]["GroupID"] != null && ds.Tables[0].Rows[0]["GroupID"].ToString() != "")
                {
                    model.GroupID = int.Parse(ds.Tables[0].Rows[0]["GroupID"].ToString());
                }
                if (ds.Tables[0].Rows[0]["BranchAddress"] != null && ds.Tables[0].Rows[0]["BranchAddress"].ToString() != "")
                {
                    model.BranchAddress = ds.Tables[0].Rows[0]["BranchAddress"].ToString();
                }
                if (ds.Tables[0].Rows[0]["City"] != null && ds.Tables[0].Rows[0]["City"].ToString() != "")
                {
                    model.City = ds.Tables[0].Rows[0]["City"].ToString();
                }
                if (ds.Tables[0].Rows[0]["BranchState"] != null && ds.Tables[0].Rows[0]["BranchState"].ToString() != "")
                {
                    model.BranchState = ds.Tables[0].Rows[0]["BranchState"].ToString();
                }
                if (ds.Tables[0].Rows[0]["Zip"] != null && ds.Tables[0].Rows[0]["Zip"].ToString() != "")
                {
                    model.Zip = ds.Tables[0].Rows[0]["Zip"].ToString();
                }
                if (ds.Tables[0].Rows[0]["WebsiteLogo"] != null && ds.Tables[0].Rows[0]["WebsiteLogo"].ToString() != "")
                {
                    model.WebsiteLogo = (byte[])ds.Tables[0].Rows[0]["WebsiteLogo"];
                }
                if (ds.Tables[0].Rows[0]["GlobalId"] != null && ds.Tables[0].Rows[0]["GlobalId"].ToString() != "")
                {
                    model.GlobalId = ds.Tables[0].Rows[0]["GlobalId"].ToString();
                }
                if (ds.Tables[0].Rows[0]["License1"] != null && ds.Tables[0].Rows[0]["License1"].ToString() != "")
                {
                    model.License1 = ds.Tables[0].Rows[0]["License1"].ToString();
                }
                if (ds.Tables[0].Rows[0]["License2"] != null && ds.Tables[0].Rows[0]["License2"].ToString() != "")
                {
                    model.License2 = ds.Tables[0].Rows[0]["License2"].ToString();
                }
                if (ds.Tables[0].Rows[0]["License3"] != null && ds.Tables[0].Rows[0]["License3"].ToString() != "")
                {
                    model.License3 = ds.Tables[0].Rows[0]["License3"].ToString();
                }
                if (ds.Tables[0].Rows[0]["License4"] != null && ds.Tables[0].Rows[0]["License4"].ToString() != "")
                {
                    model.License4 = ds.Tables[0].Rows[0]["License4"].ToString();
                }
                if (ds.Tables[0].Rows[0]["Disclaimer"] != null && ds.Tables[0].Rows[0]["Disclaimer"].ToString() != "")
                {
                    model.Disclaimer = ds.Tables[0].Rows[0]["Disclaimer"].ToString();
                }
                if (ds.Tables[0].Rows[0]["Phone"] != null && ds.Tables[0].Rows[0]["Phone"].ToString() != "")
                {
                    model.Phone = ds.Tables[0].Rows[0]["Phone"].ToString();
                }
                if (ds.Tables[0].Rows[0]["Fax"] != null && ds.Tables[0].Rows[0]["Fax"].ToString() != "")
                {
                    model.Fax = ds.Tables[0].Rows[0]["Fax"].ToString();
                }
                if (ds.Tables[0].Rows[0]["WebURL"] != null && ds.Tables[0].Rows[0]["WebURL"].ToString() != "")
                {
                    model.WebURL = ds.Tables[0].Rows[0]["WebURL"].ToString();
                }
                if (ds.Tables[0].Rows[0]["Email"] != null && ds.Tables[0].Rows[0]["Email"].ToString() != "")
                {
                    model.Email = ds.Tables[0].Rows[0]["Email"].ToString();
                }
                if (ds.Tables[0].Rows[0]["License5"] != null && ds.Tables[0].Rows[0]["License5"].ToString() != "")
                {
                    model.License5 = ds.Tables[0].Rows[0]["License5"].ToString();
                }
                if (ds.Tables[0].Rows[0]["Leadstar_Username"] != null && ds.Tables[0].Rows[0]["Leadstar_Username"].ToString() != "")
                {
                    model.Leadstar_Username = ds.Tables[0].Rows[0]["Leadstar_Username"].ToString();
                }
                if (ds.Tables[0].Rows[0]["Leadstar_ID"] != null && ds.Tables[0].Rows[0]["Leadstar_ID"].ToString() != "")
                {
                    model.Leadstar_ID = ds.Tables[0].Rows[0]["Leadstar_ID"].ToString();
                }
                if (ds.Tables[0].Rows[0]["Leadstar_Userid"] != null && ds.Tables[0].Rows[0]["Leadstar_Userid"].ToString() != "")
                {
                    model.Leadstar_Userid = ds.Tables[0].Rows[0]["Leadstar_Userid"].ToString();
                }
                if (ds.Tables[0].Rows[0]["HomeBranch"] != null && ds.Tables[0].Rows[0]["HomeBranch"].ToString() != "")
                {
                    if ((ds.Tables[0].Rows[0]["HomeBranch"].ToString() == "1") || (ds.Tables[0].Rows[0]["HomeBranch"].ToString().ToLower() == "true"))
                    {
                        model.HomeBranch = true;
                    }
                    else
                    {
                        model.HomeBranch = false;
                    }
                }
                if (ds.Tables[0].Rows[0]["EnableMailChimp"] != null && ds.Tables[0].Rows[0]["EnableMailChimp"].ToString() != "")
                {
                    if ((ds.Tables[0].Rows[0]["EnableMailChimp"].ToString() == "1") || (ds.Tables[0].Rows[0]["EnableMailChimp"].ToString().ToLower() == "true"))
                    {
                        model.EnableMailChimp = true;
                    }
                    else
                    {
                        model.EnableMailChimp = false;
                    }
                }
                if (ds.Tables[0].Rows[0]["MailChimpAPIKey"] != null && ds.Tables[0].Rows[0]["MailChimpAPIKey"].ToString() != "")
                {
                    model.MailChimpAPIKey = ds.Tables[0].Rows[0]["MailChimpAPIKey"].ToString();
                }
                return(model);
            }
            else
            {
                return(null);
            }
        }
예제 #7
0
        /// <summary>
        /// 保存Branch和Members信息
        /// </summary>
        /// <param name="iGroupID"></param>
        /// <param name="bEnabled"></param>
        /// <param name="sGroupDesc"></param>
        /// <param name="sOldGroupMemberIDs"></param>
        /// <param name="sGroupMemberIDs"></param>
        public void SaveBranchAndMembersBase(LPWeb.Model.Branches model, string sFolderIDs, string sManagers)
        {
            Collection <SqlCommand> SqlCmdList = new Collection <SqlCommand>();

            #region SQL for 更新Branches信息
            string sSql = string.Empty;
            if (model.WebsiteLogo != null)
            {
                sSql = " UPDATE [Branches] SET [Name] = @Name,[Desc] = @Desc,[WebsiteLogo] = @WebsiteLogo,[Enabled] = @Enabled, [GroupID] = @GroupID, [BranchAddress] = @BranchAddress,[City] = @City,[BranchState] = @BranchState,[Zip] = @Zip,License1=@License1,License2=@License2,License3=@License3,License4=@License4,License5=@License5,Disclaimer=@Disclaimer,Phone=@Phone,Fax=@Fax,Email=@Email,WebURL=@WebURL,HomeBranch=@HomeBranch WHERE BranchId=@BranchId ";
            }
            else
            {
                sSql = " UPDATE [Branches] SET [Name] = @Name,[Desc] = @Desc,[Enabled] = @Enabled , [GroupID] = @GroupID, [BranchAddress] = @BranchAddress,[City] = @City,[BranchState] = @BranchState,[Zip] = @Zip,License1=@License1,License2=@License2,License3=@License3,License4=@License4,License5=@License5,Disclaimer=@Disclaimer,Phone=@Phone,Fax=@Fax,Email=@Email,WebURL=@WebURL,HomeBranch=@HomeBranch WHERE BranchId=@BranchId ";
            }

            SqlCommand SqlCmd = new SqlCommand(sSql);
            DbHelperSQL.AddSqlParameter(SqlCmd, "@Name", SqlDbType.NVarChar, model.Name);
            DbHelperSQL.AddSqlParameter(SqlCmd, "@Desc", SqlDbType.NVarChar, model.Desc);
            if (model.WebsiteLogo != null)
            {
                DbHelperSQL.AddSqlParameter(SqlCmd, "@WebsiteLogo", SqlDbType.VarBinary, model.WebsiteLogo);
            }
            DbHelperSQL.AddSqlParameter(SqlCmd, "@Enabled", SqlDbType.Bit, model.Enabled);
            DbHelperSQL.AddSqlParameter(SqlCmd, "@GroupID", SqlDbType.Int, model.GroupID);
            DbHelperSQL.AddSqlParameter(SqlCmd, "@BranchAddress", SqlDbType.NVarChar, model.BranchAddress);
            DbHelperSQL.AddSqlParameter(SqlCmd, "@City", SqlDbType.NVarChar, model.City);
            DbHelperSQL.AddSqlParameter(SqlCmd, "@BranchState", SqlDbType.NVarChar, model.BranchState);
            DbHelperSQL.AddSqlParameter(SqlCmd, "@Zip", SqlDbType.NVarChar, model.Zip);
            DbHelperSQL.AddSqlParameter(SqlCmd, "@BranchId", SqlDbType.Int, model.BranchId);
            DbHelperSQL.AddSqlParameter(SqlCmd, "@License1", SqlDbType.NVarChar, model.License1);
            DbHelperSQL.AddSqlParameter(SqlCmd, "@License2", SqlDbType.NVarChar, model.License2);
            DbHelperSQL.AddSqlParameter(SqlCmd, "@License3", SqlDbType.NVarChar, model.License3);
            DbHelperSQL.AddSqlParameter(SqlCmd, "@License4", SqlDbType.NVarChar, model.License4);
            DbHelperSQL.AddSqlParameter(SqlCmd, "@License5", SqlDbType.NVarChar, model.License5);
            DbHelperSQL.AddSqlParameter(SqlCmd, "@Disclaimer", SqlDbType.NVarChar, model.Disclaimer);
            DbHelperSQL.AddSqlParameter(SqlCmd, "@Phone", SqlDbType.NVarChar, model.Phone);
            DbHelperSQL.AddSqlParameter(SqlCmd, "@Fax", SqlDbType.NVarChar, model.Fax);
            DbHelperSQL.AddSqlParameter(SqlCmd, "@Email", SqlDbType.NVarChar, model.Email);
            DbHelperSQL.AddSqlParameter(SqlCmd, "@WebURL", SqlDbType.NVarChar, model.WebURL);
            DbHelperSQL.AddSqlParameter(SqlCmd, "@HomeBranch", SqlDbType.Bit, model.HomeBranch);
            SqlCmdList.Add(SqlCmd);

            #endregion

            string     sSql5   = " UPDATE [PointFolders] SET [BranchId] = null WHERE [BranchId]=@BranchId ";
            SqlCommand SqlCmd5 = new SqlCommand(sSql5);
            DbHelperSQL.AddSqlParameter(SqlCmd5, "@BranchId", SqlDbType.Int, model.BranchId);
            SqlCmdList.Add(SqlCmd5);

            string     sSql2   = " UPDATE [PointFolders] SET [BranchId] = null WHERE [BranchId]=@BranchId ";
            SqlCommand SqlCmd2 = new SqlCommand(sSql2);
            DbHelperSQL.AddSqlParameter(SqlCmd2, "@BranchId", SqlDbType.Int, model.BranchId);
            SqlCmdList.Add(SqlCmd2);

            if (sFolderIDs != string.Empty)
            {
                string[] folders = sFolderIDs.Split("|".ToCharArray());
                foreach (string folder in folders)
                {
                    string[] folderstatus = folder.Split(",".ToCharArray());
                    if (folderstatus.Length == 2)
                    {
                        string     sSql3   = " UPDATE [PointFolders] SET [BranchId] = @BranchId,LoanStatus=@LoanStatus WHERE FolderId = @FolderId";
                        SqlCommand SqlCmd3 = new SqlCommand(sSql3);
                        DbHelperSQL.AddSqlParameter(SqlCmd3, "@BranchId", SqlDbType.Int, model.BranchId);
                        DbHelperSQL.AddSqlParameter(SqlCmd3, "@LoanStatus", SqlDbType.Int, int.Parse(folderstatus[1]));
                        DbHelperSQL.AddSqlParameter(SqlCmd3, "@FolderId", SqlDbType.Int, int.Parse(folderstatus[0]));
                        SqlCmdList.Add(SqlCmd3);
                    }
                }
            }

            #region 更新 group 表
            string     sSql9   = "EXEC GroupRelationInfoUpdate 'Branch'," + model.BranchId.ToString() + "," + model.GroupID.ToString();
            SqlCommand sqlcmd9 = new SqlCommand(sSql9);
            SqlCmdList.Add(sqlcmd9);
            //LPWeb.Model.Branches model1 = GetModel(model.BranchId);
            //string sSql9 = "UPDATE Groups SET RegionID=NULL,OrganizationType=NULL,DivisionID=NULL,BranchID=NULL WHERE BranchID=" + model.BranchId.ToString();
            //SqlCommand sqlcmd9 = new SqlCommand(sSql9);
            //SqlCmdList.Add(sqlcmd9);

            ////设置新的group属于当前region Division branch
            //string sSql10 = string.Empty;
            //if (model.GroupID.HasValue)
            //{
            //    if (model1.RegionID.HasValue && model1.DivisionID.HasValue)
            //    {
            //        sSql10 = "UPDATE Groups SET RegionID=" + model1.RegionID.ToString() + ",OrganizationType='Branch',DivisionID=" + model1.DivisionID.ToString() + ",BranchID=" + model.BranchId.ToString() + " WHERE GroupID=" + model.GroupID.ToString();
            //    }
            //    else if (model1.RegionID.HasValue && !model1.DivisionID.HasValue)
            //    {
            //        sSql10 = "UPDATE Groups SET RegionID=" + model1.RegionID.ToString() + ",OrganizationType='Branch', BranchID=" + model.BranchId.ToString() + " WHERE GroupID=" + model.GroupID.ToString();
            //    }
            //    else if (!model1.RegionID.HasValue && model1.DivisionID.HasValue)
            //    {
            //        sSql10 = "UPDATE Groups SET OrganizationType='Branch',DivisionID=" + model1.DivisionID.ToString() + ",BranchID=" + model.BranchId.ToString() + " WHERE GroupID=" + model.GroupID.ToString();
            //    }
            //    else
            //    {
            //        sSql10 = "UPDATE Groups SET OrganizationType='Branch' ,BranchID=" + model.BranchId.ToString() + " WHERE GroupID=" + model.GroupID.ToString();
            //    }
            //    SqlCommand sqlcmd10 = new SqlCommand(sSql10);
            //    SqlCmdList.Add(sqlcmd10);
            //}
            #endregion

            string     sSql4   = "DELETE BranchManagers WHERE [BranchId] = @BranchId ";
            SqlCommand SqlCmd4 = new SqlCommand(sSql4);
            DbHelperSQL.AddSqlParameter(SqlCmd4, "@BranchId", SqlDbType.Int, model.BranchId);
            SqlCmdList.Add(SqlCmd4);

            if (sManagers != string.Empty)
            {
                string[] managers = sManagers.Split(",".ToCharArray());
                foreach (string manager in managers)
                {
                    string     sSql5x   = "INSERT INTO [BranchManagers]([BranchId],[BranchMgrId])VALUES(@BranchId,@BranchMgrId )";
                    SqlCommand SqlCmd5x = new SqlCommand(sSql5x);
                    DbHelperSQL.AddSqlParameter(SqlCmd5x, "@BranchId", SqlDbType.Int, model.BranchId);
                    DbHelperSQL.AddSqlParameter(SqlCmd5x, "@BranchMgrId", SqlDbType.Int, int.Parse(manager));
                    SqlCmdList.Add(SqlCmd5x);
                }
            }

            #region 批量执行SQL

            SqlConnection  SqlConn  = null;
            SqlTransaction SqlTrans = null;
            try
            {
                SqlConn  = DbHelperSQL.GetOpenConnection();
                SqlTrans = SqlConn.BeginTransaction();

                foreach (SqlCommand xSqlCmd in SqlCmdList)
                {
                    DbHelperSQL.ExecuteNonQuery(xSqlCmd, SqlTrans);
                }

                SqlTrans.Commit();
            }
            catch (Exception ex)
            {
                SqlTrans.Rollback();
                throw ex;
            }
            finally
            {
                if (SqlConn != null)
                {
                    SqlConn.Close();
                }
            }

            #endregion
        }
예제 #8
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            #region set Default
            if (!string.IsNullOrEmpty(hifId.Value))
            {
                bool IsCancel = false;

                var val = hifId.Value.Split(':');

                if (val.Count() != 2)
                {
                    return;
                }
                IsCancel = Convert.ToBoolean(val[1]);

                PointFolders folder = new PointFolders();
                folder.SetDefaultPoint(val[0], this.iBranchID, IsCancel);
            }

            #endregion

            bool   bEnabled   = this.ckbEnabled.Checked;
            string sDesc      = this.txbDescription.Text.Trim();
            string sFolderIDs = this.hdnFolderIDs.Value;
            string sManagers  = this.hdnManagers.Value;


            LPWeb.Model.Branches model = new LPWeb.Model.Branches();
            model = branchManager.GetModel(iBranchID);
            int iOldGroupID = Convert.ToInt32(model.GroupID);
            model.BranchId = iBranchID;
            model.Enabled  = ckbEnabled.Checked;
            model.Desc     = txbDescription.Text.Trim();
            model.Name     = ddlBranchName.SelectedItem.Text;
            if (ddlGroupAccess.Items.Count > 0)
            {
                model.GroupID = int.Parse(ddlGroupAccess.SelectedValue);
            }
            else
            {
                model.GroupID = 0;
            }
            model.BranchAddress = txbAddress.Text.Trim();
            model.City          = txbCity.Text.Trim();
            model.Zip           = txbZip.Text.Trim();
            model.BranchState   = ddlState.SelectedValue.Trim();

            if (this.fuldWebLogo.HasFile && this.fuldWebLogo.FileName.ToUpper().IndexOf(".TIF") < 0)
            {
                model.WebsiteLogo = fuldWebLogo.FileBytes;
            }
            else
            {
                model.WebsiteLogo = null;
            }
            model.License1 = txbLicense1.Text.Trim();
            model.License2 = txbLicense2.Text.Trim();
            model.License3 = txbLicense3.Text.Trim();
            model.License4 = txbLicense4.Text.Trim();
            model.License5 = txbLicense5.Text.Trim();

            model.Disclaimer = txbDisclaimer.Text.Trim();

            model.Phone  = txbPhone.Text.Trim();
            model.Fax    = txbFax.Text.Trim();
            model.Email  = txbEmail.Text.Trim();
            model.WebURL = txbWebURL.Text.Trim();

            var oldHomeBranch = model.HomeBranch;
            model.HomeBranch = chkHomeBranch.Checked;


            try
            {
                if (oldHomeBranch != model.HomeBranch)
                {
                    branchManager.SetOtherHomeBranchFalse(model.BranchId);
                }
                branchManager.SaveBranchAndMembersBase(model, sFolderIDs, sManagers);
                //Save point folder enable status
                PointFolders pointFolderMgr = new PointFolders();
                if (this.hdnDisableFolderIDs.Value.Trim() != "")
                {
                    pointFolderMgr.UpdatePointFolderEnabled(this.hdnDisableFolderIDs.Value, false);
                }
                if (this.hdnEnableFolderIDs.Value.Trim() != "")
                {
                    pointFolderMgr.UpdatePointFolderEnabled(this.hdnEnableFolderIDs.Value, true);
                }
                //this.divManager.SaveDivisionAndMembersBase(this.iDivisionID, bEnabled, sDesc, sBranchMemberIDs, sExectives);
                //Save group folder info
                model = branchManager.GetModel(model.BranchId);
                GroupFolder groupFolder = new GroupFolder();
                if (model.GroupID != 0)
                {
                    groupFolder.DoSaveGroupFolder(Convert.ToInt32(model.GroupID), model.BranchId, "branch", iOldGroupID);
                }

                if (model.RegionID != 0 && model.RegionID != null)
                {
                    Regions             regMgr      = new Regions();
                    LPWeb.Model.Regions regionModel = regMgr.GetModel(Convert.ToInt32(model.RegionID));
                    if (regionModel.GroupID != null && regionModel.GroupID != 0)
                    {
                        groupFolder.DoSaveGroupFolder(Convert.ToInt32(regionModel.GroupID), Convert.ToInt32(model.RegionID), "region", Convert.ToInt32(regionModel.GroupID));
                    }
                }
                if (model.DivisionID != 0 && model.DivisionID != null)
                {
                    Divisions             divMgr   = new Divisions();
                    LPWeb.Model.Divisions divModel = divMgr.GetModel(Convert.ToInt32(model.DivisionID));
                    if (divModel.GroupID != null && divModel.GroupID != 0)
                    {
                        groupFolder.DoSaveGroupFolder(Convert.ToInt32(divModel.GroupID), Convert.ToInt32(model.DivisionID), "division", Convert.ToInt32(divModel.GroupID));
                    }
                }
                PageCommon.WriteJsEnd(this, "Branch saved successfully.", PageCommon.Js_RefreshSelf);
            }
            catch
            {
                PageCommon.WriteJsEnd(this, "Failed to save the record.", PageCommon.Js_RefreshSelf);
            }
        }
예제 #9
0
        private void FillBranch()
        {
            try
            {
                LPWeb.Model.Branches model = branchManager.GetModel(iBranchID);
                ddlBranchName.SelectedValue = iBranchID.ToString();
                ckbEnabled.Checked          = model.Enabled;

                if (model.GroupID.HasValue && ddlGroupAccess.Items.FindByValue(model.GroupID.Value.ToString()) != null)
                {
                    ddlGroupAccess.SelectedValue = model.GroupID.Value.ToString();//设置选中项
                }
                else
                {
                    ddlGroupAccess.SelectedValue = "0";
                }
                txbDescription.Text   = model.Desc;
                txbAddress.Text       = model.BranchAddress;
                txbCity.Text          = model.City;
                txbZip.Text           = model.Zip;
                ddlState.Text         = model.BranchState;
                txbPhone.Text         = model.Phone;
                txbFax.Text           = model.Fax;
                txbEmail.Text         = model.Email;
                txbWebURL.Text        = model.WebURL;
                chkHomeBranch.Checked = model.HomeBranch;
                chkHomeBranch.Attributes.Add("cid", "chkHomeBranch");
                chkHomeBranch.Attributes.Add("BranchID", model.BranchId.ToString());

                #region find HomeBranch = true  BranchId

                var homebranchId = 0;
                if (model.HomeBranch != true)
                {
                    var ds = branchManager.GetList(1, " HomeBranch = 1 ", "BranchId");

                    if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
                    {
                        homebranchId = Convert.ToInt32(ds.Tables[0].Rows[0]["BranchId"]);
                    }
                }
                else
                {
                    homebranchId = model.BranchId;
                }

                chkHomeBranch.Attributes.Add("HomeBranchID", homebranchId.ToString());

                #endregion

                if (model.WebsiteLogo == null)
                {
                    Image1.ImageUrl = "../images/YourLogo.jpg";
                }
                else if (model.WebsiteLogo.Length < 1)
                {
                    Image1.ImageUrl = "../images/YourLogo.jpg";
                }
                else
                {
                    Image1.ImageUrl = "BranchLogo.aspx?BranchID=" + iBranchID.ToString() + "&ss=" + DateTime.Now.Millisecond.ToString();
                }

                txbLicense1.Text   = model.License1;
                txbLicense2.Text   = model.License2;
                txbLicense3.Text   = model.License3;
                txbLicense4.Text   = model.License4;
                txbLicense5.Text   = model.License5;
                txbDisclaimer.Text = model.Disclaimer;
            }
            catch
            {
            }
        }