Ejemplo n.º 1
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        /// <param name="model">model</param>
        public int AddRecord(TSOutInTypeData model)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("set nocount on; ");
            strSql.Append("insert into TSOutInType(");
            strSql.Append(@"outInType,outInTypeName)");
            strSql.Append(" values (");
            strSql.Append(@"@outInType,@outInTypeName)");
            strSql.Append("; select @@identity; set nocount off; ");
            SqlParameter[] parameters = {
                    new SqlParameter("@outInType", SqlDbType.NChar,10),
                    new SqlParameter("@outInTypeName", SqlDbType.NVarChar,50)
                };
            parameters[0].Value = model.outInType;
            parameters[1].Value = model.outInTypeName;

            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;
        }
Ejemplo n.º 2
0
    /// <summary>
    /// 数据保存
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void btnSave_Click(object sender, EventArgs e)
    {
        string strInfo = "";

        if (!this.ValidateData(out strInfo))
        {
            strInfo = strInfo.Replace("\"", "'").Replace("\n", "");
            this.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert('" + strInfo + "');", true);
            return;
        }

        TSOutInTypeData model = new TSOutInTypeData();
        TSOutInTypeBB tsOutInTypeBB = new TSOutInTypeBB();

        try
        {
            if (this.State == "1")
            {
                this.SetModel(ref model);
                this.IdValue = tsOutInTypeBB.AddRecord(model);
            }
            else if (this.State == "2")
            {
                model = tsOutInTypeBB.GetModel(this.IdValue);
                this.SetModel(ref model);

                tsOutInTypeBB.ModifyRecord(model);
            }
        }
        catch (Exception ex)
        {
            this.ClientScript.RegisterStartupScript(this.GetType(), "ShowErr", "ShowErr(\"" + Server.UrlEncode(ex.Message) + "\",3);", true);
            return;
        }
        finally
        {
            tsOutInTypeBB.Dispose();
        }

        Response.Redirect("LTsOutInList.aspx?&itemno=" + this.itemNo + "&pTypeNo=main", false);
    }
Ejemplo n.º 3
0
    /// <summary>
    /// 展示数据
    /// </summary>
    /// <param name="id">记录Id</param>
    private void ShowInfo(int id)
    {
        TSOutInTypeBB noPassReasonBB = new TSOutInTypeBB();
        TSOutInTypeData model = new TSOutInTypeData();
        try
        {
            model = noPassReasonBB.GetModel(id);
            this.tbOutInName.Text = model.outInTypeName;

            this.ddlCheckItem.SelectedValue = model.outInType;
        }
        finally
        {
            noPassReasonBB.Dispose();
        }
    }
Ejemplo n.º 4
0
 /// <summary>
 /// 实体类赋值
 /// </summary>
 /// <param name="model">实体类实例</param>
 private void SetModel(ref TSOutInTypeData model)
 {
     if (this.ddlCheckItem.SelectedValue.ToString() == "特殊入库")
     {
         model.outInType = "01";
     }
     else
     {
         model.outInType = "02";
     }
     model.outInTypeName = this.tbOutInName.Text;
 }
Ejemplo n.º 5
0
        /// <summary>
        /// 更新一条"TSOutInType"信息
        /// </summary>
        /// <param name="model">model</param>
        public bool ModifyRecord(TSOutInTypeData model)
        {
            bool ret = false;
            SqlTransaction trans = null;
            try
            {
                if (this.transaction == null)
                {
                    trans = this.connection.BeginTransaction("TransModify");
                    this.sOutInTypeBB.Transaction = trans;
                    this.errorDiaryBB.Transaction = trans;
                    this.operatDiaryBB.Transaction = trans;
                }

                this.sOutInTypeBB.ModifyRecord(model);

                SOperatDiaryData operatDiaryData = new SOperatDiaryData();
                operatDiaryData.empId = this.empId;
                operatDiaryData.functionId = "";
                operatDiaryData.recordId = model.id.ToString();
                operatDiaryData.operateContent = "TSOutInType修改一条id为“" + model.id.ToString() + "”的记录";
                this.operatDiaryBB.AddRecord(operatDiaryData);

                if (this.transaction == null) trans.Commit();
                ret = true;
            }
            catch (Exception ex)
            {
                if (this.transaction == null) trans.Rollback("TransModify");
                SErrorDiaryData errorDiaryData = new SErrorDiaryData();
                errorDiaryData.empId = this.empId;
                errorDiaryData.functionId = "";
                errorDiaryData.errorText = "TSOutInType修改记录“" + model.id.ToString() + "”时报错:" + ex.Message;
                this.errorDiaryBB.AddRecord(errorDiaryData);
                throw ex;
            }
            finally
            {
            }
            return ret;
        }
Ejemplo n.º 6
0
        /// <summary>
        /// 增加一条"TSOutInType"信息
        /// </summary>
        /// <param name="model">model</param>
        public int AddRecord(TSOutInTypeData model)
        {
            int id = 0;
            SqlTransaction trans = null;
            try
            {
                if (this.transaction == null)
                {
                    trans = this.connection.BeginTransaction("TransAdd");
                    this.sOutInTypeBB.Transaction = trans;
                    this.errorDiaryBB.Transaction = trans;
                    this.operatDiaryBB.Transaction = trans;
                }

                id = this.sOutInTypeBB.AddRecord(model);

                SOperatDiaryData operatDiaryData = new SOperatDiaryData();
                operatDiaryData.empId = this.empId;
                operatDiaryData.functionId = "";
                operatDiaryData.recordId = id.ToString();
                operatDiaryData.operateContent = "TSOutInType增加一条id为“" + id.ToString() + "”的记录";
                this.operatDiaryBB.AddRecord(operatDiaryData);

                if (this.transaction == null) trans.Commit();
            }
            catch (Exception ex)
            {
                if (this.transaction == null) trans.Rollback("TransAdd");
                SErrorDiaryData errorDiaryData = new SErrorDiaryData();
                errorDiaryData.empId = this.empId;
                errorDiaryData.functionId = "";
                errorDiaryData.errorText = "TSOutInType增加记录时报错:" + ex.Message;
                this.errorDiaryBB.AddRecord(errorDiaryData);
                throw ex;
            }
            finally
            {
            }
            return id;
        }
Ejemplo n.º 7
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 /// <param name="model">model</param>
 public bool ModifyRecord(TSOutInTypeData model)
 {
     return this.sOutInTypeDB.ModifyRecord(model);
 }
Ejemplo n.º 8
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 /// <param name="model">model</param>
 public int AddRecord(TSOutInTypeData model)
 {
     return this.sOutInTypeDB.AddRecord(model);
 }
Ejemplo n.º 9
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        /// <param name="model">model</param>
        public bool ModifyRecord(TSOutInTypeData model)
        {
            bool ret = false;
            StringBuilder strSql = new StringBuilder();
            strSql.Append("update TSOutInType set ");
            strSql.Append("outInType=@outInType,");
            strSql.Append("outInTypeName=@outInTypeName");
            strSql.Append(" where id = @id ");
            SqlParameter[] parameters = {
                    new SqlParameter("@id", SqlDbType.Int),
                    new SqlParameter("@outInType", SqlDbType.NChar,10),
                    new SqlParameter("@outInTypeName", SqlDbType.NVarChar,50)
                };
            parameters[0].Value = model.id;
            parameters[1].Value = model.outInType;
            parameters[2].Value = model.outInTypeName;

            try
            {
                SqlHelper.ExecuteNonQuery(this.connection, this.transaction, CommandType.Text, strSql.ToString(), parameters);
                ret = true;
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return ret;
        }
Ejemplo n.º 10
0
        /// <summary>
        /// 得到一个model
        /// </summary>
        /// <param name="id">主键值</param>
        /// <returns>model</returns>
        public TSOutInTypeData GetModel(int id)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append(@"select id, case outInType when '01' then '特殊入库' when '02' then '特殊出库' end as outInType,outInTypeName from TSOutInType");
            strSql.Append(" where id = @id ");
            SqlParameter[] parameters = {
                    new SqlParameter("@id", SqlDbType.Int)
                };
            parameters[0].Value = id;

            TSOutInTypeData model = new TSOutInTypeData();
            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["outInType"] != DBNull.Value)
                {
                    model.outInType = Convert.ToString(row["outInType"]);
                }
                if (row["outInTypeName"] != DBNull.Value)
                {
                    model.outInTypeName = Convert.ToString(row["outInTypeName"]);
                }
                return model;
            }
            else
            {
                return null;
            }
        }