Exemple #1
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public void Update(Dianda.Model.USER_ORGAN model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update USER_ORGAN set ");
            strSql.Append("NAME=@NAME,");
            strSql.Append("PID=@PID,");
            strSql.Append("ISMAIN=@ISMAIN,");
            strSql.Append("DELFLAG=@DELFLAG,");
            strSql.Append("PATH=@PATH,");
            strSql.Append("TYPES=@TYPES,");
            strSql.Append("INFOR=@INFOR,");
            strSql.Append("INFOR2=@INFOR2");
            strSql.Append(" where ID=@ID ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@ID",      SqlDbType.VarChar,  50),
                new SqlParameter("@NAME",    SqlDbType.VarChar, 100),
                new SqlParameter("@PID",     SqlDbType.VarChar,  50),
                new SqlParameter("@ISMAIN",  SqlDbType.Int,       4),
                new SqlParameter("@DELFLAG", SqlDbType.Int,       4),
                new SqlParameter("@PATH",    SqlDbType.VarChar, 500),
                new SqlParameter("@TYPES",   SqlDbType.VarChar,  50),
                new SqlParameter("@INFOR",   SqlDbType.Text),
                new SqlParameter("@INFOR2",  SqlDbType.Text)
            };
            parameters[0].Value = model.ID;
            parameters[1].Value = model.NAME;
            parameters[2].Value = model.PID;
            parameters[3].Value = model.ISMAIN;
            parameters[4].Value = model.DELFLAG;
            parameters[5].Value = model.PATH;
            parameters[6].Value = model.TYPES;
            parameters[7].Value = model.INFOR;
            parameters[8].Value = model.INFOR2;

            if (model.ISMAIN == 1)                  //如果是总校,修改其他ismain为0
            {
                StringBuilder strSql1 = new StringBuilder();
                strSql1.Append("update USER_ORGAN set ");
                strSql1.Append("ISMAIN=0 where delflag=0");
                SqlParameter[] parameters1 =
                {
                };
                DbHelperSQL.ExecuteSql(strSql1.ToString(), parameters1);
            }

            DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);
        }
Exemple #2
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public void Add(Dianda.Model.USER_ORGAN model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into USER_ORGAN(");
            strSql.Append("ID,NAME,PID,ISMAIN,DELFLAG,PATH,TYPES,INFOR,INFOR2)");
            strSql.Append(" values (");
            strSql.Append("@ID,@NAME,@PID,@ISMAIN,@DELFLAG,@PATH,@TYPES,@INFOR,@INFOR2)");
            SqlParameter[] parameters =
            {
                new SqlParameter("@ID",      SqlDbType.VarChar,  50),
                new SqlParameter("@NAME",    SqlDbType.VarChar, 100),
                new SqlParameter("@PID",     SqlDbType.VarChar,  50),
                new SqlParameter("@ISMAIN",  SqlDbType.Int,       4),
                new SqlParameter("@DELFLAG", SqlDbType.Int,       4),
                new SqlParameter("@PATH",    SqlDbType.VarChar, 500),
                new SqlParameter("@TYPES",   SqlDbType.VarChar,  50),
                new SqlParameter("@INFOR",   SqlDbType.Text),
                new SqlParameter("@INFOR2",  SqlDbType.Text)
            };
            parameters[0].Value = model.ID;
            parameters[1].Value = model.NAME;
            parameters[2].Value = model.PID;
            parameters[3].Value = model.ISMAIN;
            parameters[4].Value = model.DELFLAG;
            parameters[5].Value = model.PATH;
            parameters[6].Value = model.TYPES;
            parameters[7].Value = model.INFOR;
            parameters[8].Value = model.INFOR2;
            if (model.ISMAIN == 1)                  //如果是总校,修改其他ismain为0
            {
                StringBuilder strSql1 = new StringBuilder();
                strSql1.Append("update USER_ORGAN set ");
                strSql1.Append("ISMAIN=0 where delflag=0");
                SqlParameter[] parameters1 =
                {
                };
                DbHelperSQL.ExecuteSql(strSql1.ToString(), parameters1);
            }

            DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);
        }
Exemple #3
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Dianda.Model.USER_ORGAN GetModel(string ID)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 ID,NAME,PID,ISMAIN,DELFLAG,PATH,TYPES,INFOR,INFOR2 from USER_ORGAN ");
            strSql.Append(" where ID=@ID ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@ID", SqlDbType.VarChar, 50)
            };
            parameters[0].Value = ID;

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

            if (ds.Tables[0].Rows.Count > 0)
            {
                model.ID   = ds.Tables[0].Rows[0]["ID"].ToString();
                model.NAME = ds.Tables[0].Rows[0]["NAME"].ToString();
                model.PID  = ds.Tables[0].Rows[0]["PID"].ToString();
                if (ds.Tables[0].Rows[0]["ISMAIN"].ToString() != "")
                {
                    model.ISMAIN = int.Parse(ds.Tables[0].Rows[0]["ISMAIN"].ToString());
                }
                if (ds.Tables[0].Rows[0]["DELFLAG"].ToString() != "")
                {
                    model.DELFLAG = int.Parse(ds.Tables[0].Rows[0]["DELFLAG"].ToString());
                }
                model.PATH   = ds.Tables[0].Rows[0]["PATH"].ToString();
                model.TYPES  = ds.Tables[0].Rows[0]["TYPES"].ToString();
                model.INFOR  = ds.Tables[0].Rows[0]["INFOR"].ToString();
                model.INFOR2 = ds.Tables[0].Rows[0]["INFOR2"].ToString();
                return(model);
            }
            else
            {
                return(null);
            }
        }
Exemple #4
0
        /// <summary>
        /// 当GridView1绑定完毕数据集后,可以通过RowDataBound事件给该GRIDVIEW中数据做切合实际的转换
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            try
            {
                if (e.Row.RowType == DataControlRowType.DataRow) //判断是否是DataRow,以防止鼠标经过Header也有效果
                {
                    e.Row.Attributes.Add("onmouseover", "e=this.style.backgroundColor; this.style.backgroundColor='#F4F4F4'");
                    e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=e");

                    string usernames = DataBinder.Eval(e.Row.DataItem, "USERNAME").ToString();
                    string ID        = Convert.ToString(DataBinder.Eval(e.Row.DataItem, "ID"));//获取到列表中的每条记录的ID

                    string organ = DataBinder.Eval(e.Row.DataItem, "ORGAN").ToString();

                    string organName = "";
                    if (organ != "" && organ != null)
                    {
                        try
                        {
                            Model.USER_ORGAN organModel = new Dianda.Model.USER_ORGAN();
                            BLL.USER_ORGAN   organBll   = new Dianda.BLL.USER_ORGAN();
                            organModel = organBll.GetModel(organ);
                            if (organModel.ID.ToString() != "")
                            {
                                organName = organModel.NAME.ToString();
                            }
                        }
                        catch
                        {
                        }
                    }
                    e.Row.Cells[4].Text = organName;
                }
            }
            catch
            {
            }
        }