Beispiel #1
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Entity.BASE_TERM GetEntity(decimal TERMID)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select TERMID, DEPTID, TERMCODE, TERMNAME, SERIALCODE, FORMAT, BRAND, USE, USETIME, SAVEPOINT, REMARK, STATUS, TYPEID  ");
            strSql.Append("  from BASE_TERM ");
            strSql.Append(" where TERMID=:TERMID ");
            OracleParameter[] parameters =
            {
                new OracleParameter(":TERMID", OracleType.Number, 4)
            };
            parameters[0].Value = TERMID;


            Entity.BASE_TERM entity = new Entity.BASE_TERM();
            DataTable        dt     = OracleHelper.Query(CommandType.Text, strSql.ToString(), parameters);

            if (dt.Rows.Count > 0)
            {
                if (dt.Rows[0]["TERMID"].ToString() != "")
                {
                    entity.TERMID = decimal.Parse(dt.Rows[0]["TERMID"].ToString());
                }
                if (dt.Rows[0]["DEPTID"].ToString() != "")
                {
                    entity.DEPTID = decimal.Parse(dt.Rows[0]["DEPTID"].ToString());
                }
                entity.TERMCODE   = dt.Rows[0]["TERMCODE"].ToString();
                entity.TERMNAME   = dt.Rows[0]["TERMNAME"].ToString();
                entity.SERIALCODE = dt.Rows[0]["SERIALCODE"].ToString();
                entity.FORMAT     = dt.Rows[0]["FORMAT"].ToString();
                entity.BRAND      = dt.Rows[0]["BRAND"].ToString();
                entity.USE        = dt.Rows[0]["USE"].ToString();
                if (dt.Rows[0]["USETIME"].ToString() != "")
                {
                    entity.USETIME = DateTime.Parse(dt.Rows[0]["USETIME"].ToString());
                }
                entity.SAVEPOINT = dt.Rows[0]["SAVEPOINT"].ToString();
                entity.REMARK    = dt.Rows[0]["REMARK"].ToString();
                if (dt.Rows[0]["STATUS"].ToString() != "")
                {
                    entity.STATUS = decimal.Parse(dt.Rows[0]["STATUS"].ToString());
                }
                if (dt.Rows[0]["TYPEID"].ToString() != "")
                {
                    entity.TYPEID = decimal.Parse(dt.Rows[0]["TYPEID"].ToString());
                }

                return(entity);
            }
            else
            {
                return(null);
            }
        }
Beispiel #2
0
 protected void btnSubmit_Click(object sender, EventArgs e)
 {
     Entity.BASE_TERM model = GetEntity();
     if (ViewState["id"] == null)
     {
         bll.Add(model);
     }
     else
     {
         bll.update(model);
     }
     Response.Redirect("Term.aspx", true);
 }
Beispiel #3
0
        //初始化实体到页面
        private void SetEntity(Entity.BASE_TERM model)
        {
            DropDownList ddr = (DropDownList)this.Department1.FindControl("ddlDepartment"); //找到用户控件中的子控件

            this.txtUSETIME.Text    = model.BRAND;                                          //制造厂商
            ddr.SelectedValue       = model.DEPTID.ToString();                              //所属单位;
            this.txtFORMAT.Text     = model.FORMAT;                                         //规格型号
            this.txtRemark.Text     = model.REMARK;                                         //备注
            this.TxtPosition.Text   = model.SAVEPOINT;                                      //存放地点
            this.txtSERIALCODE.Text = model.SERIALCODE;                                     //出厂编号
            //model.STATUS = 0;//状态(0:正常;1:删除)
            this.txtTERMCODE.Text          = model.TERMCODE;                                //设备编号
            this.hidPrimary.Value          = model.TERMID.ToString();                       //主键,编号
            this.txtTERMNAME.Text          = model.TERMNAME;                                //设备名称
            this.ddlTermType.SelectedValue = model.TYPEID.ToString();                       //装备类型
            this.txtUse.Text     = model.USE;                                               //装备用途
            this.txtUSETIME.Text = model.USETIME.ToString();                                //投入使用时间
        }
Beispiel #4
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public void Add(Entity.BASE_TERM entity)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into BASE_TERM(");
            strSql.Append("TERMID,DEPTID,TERMCODE,TERMNAME,SERIALCODE,FORMAT,BRAND,USE,USETIME,SAVEPOINT,REMARK,STATUS,TYPEID");
            strSql.Append(") values (");
            strSql.Append(":TERMID,:DEPTID,:TERMCODE,:TERMNAME,:SERIALCODE,:FORMAT,:BRAND,:USE,:USETIME,:SAVEPOINT,:REMARK,:STATUS,:TYPEID");
            strSql.Append(") ");

            OracleParameter[] parameters =
            {
                new OracleParameter(":TERMID",     OracleType.Number,     4),
                new OracleParameter(":DEPTID",     OracleType.Number,     4),
                new OracleParameter(":TERMCODE",   OracleType.VarChar,   50),
                new OracleParameter(":TERMNAME",   OracleType.VarChar,   50),
                new OracleParameter(":SERIALCODE", OracleType.VarChar,   50),
                new OracleParameter(":FORMAT",     OracleType.VarChar,   50),
                new OracleParameter(":BRAND",      OracleType.VarChar,   50),
                new OracleParameter(":USE",        OracleType.VarChar,   50),
                new OracleParameter(":USETIME",    OracleType.DateTime),
                new OracleParameter(":SAVEPOINT",  OracleType.VarChar,   50),
                new OracleParameter(":REMARK",     OracleType.VarChar,   50),
                new OracleParameter(":STATUS",     OracleType.Number,     4),
                new OracleParameter(":TYPEID",     OracleType.Number, 4)
            };

            parameters[0].Value  = entity.TERMID;
            parameters[1].Value  = entity.DEPTID;
            parameters[2].Value  = entity.TERMCODE;
            parameters[3].Value  = entity.TERMNAME;
            parameters[4].Value  = entity.SERIALCODE;
            parameters[5].Value  = entity.FORMAT;
            parameters[6].Value  = entity.BRAND;
            parameters[7].Value  = entity.USE;
            parameters[8].Value  = entity.USETIME;
            parameters[9].Value  = entity.SAVEPOINT;
            parameters[10].Value = entity.REMARK;
            parameters[11].Value = entity.STATUS;
            parameters[12].Value = entity.TYPEID;
            OracleHelper.ExecuteNonQuery(strSql.ToString(), parameters);
        }
Beispiel #5
0
        //从页面获取实体
        private Entity.BASE_TERM GetEntity()
        {
            Entity.BASE_TERM model = new Entity.BASE_TERM();
            DropDownList     ddr   = (DropDownList)this.Department1.FindControl("ddlDepartment"); //找到用户控件中的子控件

            model.BRAND      = this.txtUSETIME.Text;                                              //制造厂商
            model.DEPTID     = Convert.ToDecimal(ddr.SelectedValue);                              //所属单位;
            model.FORMAT     = this.txtFORMAT.Text;                                               //规格型号
            model.REMARK     = this.txtRemark.Text;                                               //备注
            model.SAVEPOINT  = this.TxtPosition.Text;                                             //存放地点
            model.SERIALCODE = this.txtSERIALCODE.Text;                                           //出厂编号
            model.STATUS     = 0;                                                                 //状态(0:正常;1:删除)
            model.TERMCODE   = this.txtTERMCODE.Text;                                             //设备编号
            model.TERMID     = Convert.ToDecimal(this.hidPrimary.Value);                          //主键,编号
            model.TERMNAME   = this.txtTERMNAME.Text;                                             //设备名称
            model.TYPEID     = Convert.ToDecimal(this.ddlTermType.SelectedValue);                 //装备类型
            model.USE        = this.txtUse.Text;                                                  //装备用途
            model.USETIME    = Convert.ToDateTime(this.txtUSETIME.Text);                          //投入使用时间

            return(model);
        }
Beispiel #6
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         if (null == Request.QueryString["id"] || "" == Request.QueryString["id"])
         {
             //添加状态页面
             this.LabName.Text = "添加装备";
         }
         else
         {
             //编辑状态绑定
             this.LabName.Text = "编辑装备信息";
             decimal Epid = Convert.ToDecimal(Request.QueryString["id"]);
             ViewState["id"] = Request.QueryString["id"];
             Entity.BASE_TERM model = bll.getModel(Epid);
             SetEntity(model);
         }
         BinfTermTypeData();
     }
 }
Beispiel #7
0
 /// <summary>
 /// 更新
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public bool update(Entity.BASE_TERM model)
 {
     return(termDal.Update(model));
 }
Beispiel #8
0
 /// <summary>
 /// 添加一条信息
 /// </summary>
 /// <param name="model"></param>
 public void Add(Entity.BASE_TERM model)
 {
     termDal.Add(model);
 }
Beispiel #9
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(Entity.BASE_TERM entity)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update BASE_TERM set ");

            strSql.Append(" TERMID = :TERMID , ");
            strSql.Append(" DEPTID = :DEPTID , ");
            strSql.Append(" TERMCODE = :TERMCODE , ");
            strSql.Append(" TERMNAME = :TERMNAME , ");
            strSql.Append(" SERIALCODE = :SERIALCODE , ");
            strSql.Append(" FORMAT = :FORMAT , ");
            strSql.Append(" BRAND = :BRAND , ");
            strSql.Append(" USE = :USE , ");
            strSql.Append(" USETIME = :USETIME , ");
            strSql.Append(" SAVEPOINT = :SAVEPOINT , ");
            strSql.Append(" REMARK = :REMARK , ");
            strSql.Append(" STATUS = :STATUS , ");
            strSql.Append(" TYPEID = :TYPEID  ");
            strSql.Append(" where TERMID=:TERMID  ");

            OracleParameter[] parameters =
            {
                new OracleParameter(":TERMID",     OracleType.Number,     4),
                new OracleParameter(":DEPTID",     OracleType.Number,     4),
                new OracleParameter(":TERMCODE",   OracleType.VarChar,   50),
                new OracleParameter(":TERMNAME",   OracleType.VarChar,   50),
                new OracleParameter(":SERIALCODE", OracleType.VarChar,   50),
                new OracleParameter(":FORMAT",     OracleType.VarChar,   50),
                new OracleParameter(":BRAND",      OracleType.VarChar,   50),
                new OracleParameter(":USE",        OracleType.VarChar,   50),
                new OracleParameter(":USETIME",    OracleType.DateTime),
                new OracleParameter(":SAVEPOINT",  OracleType.VarChar,   50),
                new OracleParameter(":REMARK",     OracleType.VarChar,   50),
                new OracleParameter(":STATUS",     OracleType.Number,     4),
                new OracleParameter(":TYPEID",     OracleType.Number, 4)
            };

            parameters[13].Value = entity.TERMID;
            parameters[14].Value = entity.DEPTID;
            parameters[15].Value = entity.TERMCODE;
            parameters[16].Value = entity.TERMNAME;
            parameters[17].Value = entity.SERIALCODE;
            parameters[18].Value = entity.FORMAT;
            parameters[19].Value = entity.BRAND;
            parameters[20].Value = entity.USE;
            parameters[21].Value = entity.USETIME;
            parameters[22].Value = entity.SAVEPOINT;
            parameters[23].Value = entity.REMARK;
            parameters[24].Value = entity.STATUS;
            parameters[25].Value = entity.TYPEID;
            int rows = OracleHelper.ExecuteNonQuery(strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }