/// <summary>
    /// 数据保存
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void btnSave_Click(object sender, EventArgs e)
    {
        LCheckItemData model = new LCheckItemData();
        LCheckItemBB checkItemBB = new LCheckItemBB();
        string strInfo = "";
        bool isSuccess = this.ValidatePageControlValue(out strInfo);
        if (isSuccess)
        {
            try
            {
                if (this.State == "1")
                {
                    this.SetModel(ref model);
                    model.isrtDt = DateTime.Now.ToString();
                    model.isrtEmpId = this.currentUser.empId;
                    this.IdValue = checkItemBB.AddRecord(model);
                }
                else if (this.State == "2")
                {
                    model = checkItemBB.GetModel(this.IdValue);
                    this.SetModel(ref model);
                    model.updtDt = DateTime.Now.ToString();
                    model.updtEmpId = this.currentUser.empId;
                    checkItemBB.ModifyRecord(model);
                }
            }
            catch (Exception ex)
            {
                this.ClientScript.RegisterStartupScript(this.GetType(), "ShowErr", "ShowErr(\"" + Server.UrlEncode(ex.Message) + "\",3);", true);
                return;
            }
            finally
            {
                checkItemBB.Dispose();
            }

            Response.Redirect("LCheckItemList.aspx?&itemno=" + this.itemNo + "&pTypeNo=main", false);
        }
        else
        {
            this.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert('" + strInfo + "');", true);
        }
    }
示例#2
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        /// <param name="model">model</param>
        public int AddRecord(LCheckItemData model)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("set nocount on; ");
            strSql.Append("insert into LCheckItem(");
            strSql.Append(@"checkItemNo,checkItemNm,mark,isrtEmpId,isrtDt,updtEmpId,updtDt)");
            strSql.Append(" values (");
            strSql.Append(@"@checkItemNo,@checkItemNm,@mark,@isrtEmpId,@isrtDt,@updtEmpId,@updtDt)");
            strSql.Append("; select @@identity; set nocount off; ");
            SqlParameter[] parameters = {
                    new SqlParameter("@checkItemNo", SqlDbType.VarChar,20),
                    new SqlParameter("@checkItemNm", SqlDbType.NVarChar,50),
                    new SqlParameter("@mark", SqlDbType.NVarChar,500),
                    new SqlParameter("@isrtEmpId", SqlDbType.Int),
                    new SqlParameter("@isrtDt", SqlDbType.DateTime),
                    new SqlParameter("@updtEmpId", SqlDbType.Int),
                    new SqlParameter("@updtDt", SqlDbType.DateTime)
                };
            parameters[0].Value = model.checkItemNo;
            parameters[1].Value = model.checkItemNm;
            parameters[2].Value = model.mark;
            parameters[3].Value = model.isrtEmpId;
            parameters[4].Value = model.isrtDt == string.Empty ? null : model.isrtDt;
            parameters[5].Value = model.updtEmpId;
            parameters[6].Value = model.updtDt == string.Empty ? null : model.updtDt;

            int id = 0;
            try
            {
                object ret = SqlHelper.ExecuteScalar(this.connection, this.transaction, CommandType.Text, strSql.ToString(), parameters);

                if (ret != null && ret != DBNull.Value)
                {
                    id = Convert.ToInt32(ret);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return id;
        }
示例#3
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        /// <param name="model">model</param>
        public bool ModifyRecord(LCheckItemData model)
        {
            bool ret = false;
            StringBuilder strSql = new StringBuilder();
            strSql.Append("update LCheckItem set ");
            strSql.Append("checkItemNo=@checkItemNo,");
            strSql.Append("checkItemNm=@checkItemNm,");
            strSql.Append("mark=@mark,");
            strSql.Append("isrtEmpId=@isrtEmpId,");
            strSql.Append("isrtDt=@isrtDt,");
            strSql.Append("updtEmpId=@updtEmpId,");
            strSql.Append("updtDt=@updtDt");
            strSql.Append(" where id = @id ");
            SqlParameter[] parameters = {
                    new SqlParameter("@id", SqlDbType.Int),
                    new SqlParameter("@checkItemNo", SqlDbType.VarChar,20),
                    new SqlParameter("@checkItemNm", SqlDbType.NVarChar,50),
                    new SqlParameter("@mark", SqlDbType.NVarChar,500),
                    new SqlParameter("@isrtEmpId", SqlDbType.Int),
                    new SqlParameter("@isrtDt", SqlDbType.DateTime),
                    new SqlParameter("@updtEmpId", SqlDbType.Int),
                    new SqlParameter("@updtDt", SqlDbType.DateTime)
                };
            parameters[0].Value = model.id;
            parameters[1].Value = model.checkItemNo;
            parameters[2].Value = model.checkItemNm;
            parameters[3].Value = model.mark;
            parameters[4].Value = model.isrtEmpId;
            parameters[5].Value = model.isrtDt == string.Empty ? null : model.isrtDt;
            parameters[6].Value = model.updtEmpId;
            parameters[7].Value = model.updtDt == string.Empty ? null : model.updtDt;

            try
            {
                SqlHelper.ExecuteNonQuery(this.connection, this.transaction, CommandType.Text, strSql.ToString(), parameters);
                ret = true;
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return ret;
        }
示例#4
0
        /// <summary>
        /// 得到一个model
        /// </summary>
        /// <param name="id">主键值</param>
        /// <returns>model</returns>
        public LCheckItemData GetModel(int id)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append(@"select id,checkItemNo,checkItemNm,mark,isrtEmpId,isrtDt,updtEmpId,updtDt from LCheckItem");
            strSql.Append(" where id = @id ");
            SqlParameter[] parameters = {
                    new SqlParameter("@id", SqlDbType.Int)
                };
            parameters[0].Value = id;

            LCheckItemData model = new LCheckItemData();
            DataSet ds = SqlHelper.ExecuteDataset(this.connection, this.transaction, CommandType.Text, strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                DataRow row = ds.Tables[0].Rows[0];
                if (row["id"] != DBNull.Value)
                {
                    model.id = Convert.ToInt32(row["id"]);
                }
                if (row["checkItemNo"] != DBNull.Value)
                {
                    model.checkItemNo = Convert.ToString(row["checkItemNo"]);
                }
                if (row["checkItemNm"] != DBNull.Value)
                {
                    model.checkItemNm = Convert.ToString(row["checkItemNm"]);
                }
                if (row["mark"] != DBNull.Value)
                {
                    model.mark = Convert.ToString(row["mark"]);
                }
                if (row["isrtEmpId"] != DBNull.Value)
                {
                    model.isrtEmpId = Convert.ToInt32(row["isrtEmpId"]);
                }
                if (row["isrtDt"] != DBNull.Value)
                {
                    model.isrtDt = Convert.ToString(row["isrtDt"]);
                }
                if (row["updtEmpId"] != DBNull.Value)
                {
                    model.updtEmpId = Convert.ToInt32(row["updtEmpId"]);
                }
                if (row["updtDt"] != DBNull.Value)
                {
                    model.updtDt = Convert.ToString(row["updtDt"]);
                }
                return model;
            }
            else
            {
                return null;
            }
        }
示例#5
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 /// <param name="model">model</param>
 public bool ModifyRecord(LCheckItemData model)
 {
     return this.checkItemDB.ModifyRecord(model);
 }
示例#6
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 /// <param name="model">model</param>
 public int AddRecord(LCheckItemData model)
 {
     return this.checkItemDB.AddRecord(model);
 }
 /// <summary>
 /// 展示数据
 /// </summary>
 /// <param name="id">记录Id</param>
 private void ShowInfo(int id)
 {
     LCheckItemBB checkItemBB = new LCheckItemBB();
     LCheckItemData model = new LCheckItemData();
     try
     {
         model = checkItemBB.GetModel(id);
         this.checkItemNo.Text = model.checkItemNo;
         this.checkItemNm.Text = model.checkItemNm;
         this.mark.Text = model.mark;
     }
     finally
     {
         checkItemBB.Dispose();
     }
 }
 /// <summary>
 /// 实体类赋值
 /// </summary>
 /// <param name="model">实体类实例</param>
 private void SetModel(ref LCheckItemData model)
 {
     model.checkItemNo = this.checkItemNo.Text;
     model.checkItemNm = this.checkItemNm.Text;
     model.mark = this.mark.Text;
 }