Exemplo n.º 1
0
 /// <summary>
 /// 从steelmodel进行添加
 /// </summary>
 /// <param name="updateDel"></param>
 /// <param name="curPage"></param>
 /// <param name="model"></param>
 public FrmAddPurchaseInfo(Action <int> updateDel, int curPage, SteelManagement.Model.SteelInfo model)
 {
     this.StartPosition = FormStartPosition.CenterParent;
     InitializeComponent();
     _updateDel      = updateDel;
     _curPage        = curPage;
     _steelInfomodel = model;
 }
Exemplo n.º 2
0
 public FrmAddSteelInfo(Action <int> updateDel, int curPage, bool is4Modify = false, SteelManagement.Model.SteelInfo model = null)
 {
     this.StartPosition = FormStartPosition.CenterParent;
     InitializeComponent();
     _updateDel = updateDel;
     _curPage   = curPage;
     _is4Modify = is4Modify;
     _model     = model;
 }
Exemplo n.º 3
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(SteelManagement.Model.SteelInfo model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update SteelInfo set ");
            strSql.Append("EntryTime=@EntryTime,");
            strSql.Append("Name=@Name,");
            strSql.Append("Size=@Size,");
            strSql.Append("Texture=@Texture,");
            strSql.Append("ProducePlace=@ProducePlace,");
            strSql.Append("Price=@Price,");
            strSql.Append("Fluctuation=@Fluctuation,");
            strSql.Append("Remark=@Remark,");
            strSql.Append("State=@State,");
            strSql.Append("InfoTime=@InfoTime");
            strSql.Append(" where Id=@Id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@EntryTime",    SqlDbType.DateTime),
                new SqlParameter("@Name",         SqlDbType.VarChar,   50),
                new SqlParameter("@Size",         SqlDbType.VarChar,   50),
                new SqlParameter("@Texture",      SqlDbType.VarChar,   50),
                new SqlParameter("@ProducePlace", SqlDbType.VarChar,   50),
                new SqlParameter("@Price",        SqlDbType.Money,      8),
                new SqlParameter("@Fluctuation",  SqlDbType.Money,      8),
                new SqlParameter("@Remark",       SqlDbType.VarChar,   50),
                new SqlParameter("@State",        SqlDbType.VarChar,   50),
                new SqlParameter("@InfoTime",     SqlDbType.DateTime),
                new SqlParameter("@Id",           SqlDbType.Int, 4)
            };
            parameters[0].Value  = model.EntryTime;
            parameters[1].Value  = model.Name;
            parameters[2].Value  = model.Size;
            parameters[3].Value  = model.Texture;
            parameters[4].Value  = model.ProducePlace;
            parameters[5].Value  = model.Price;
            parameters[6].Value  = model.Fluctuation;
            parameters[7].Value  = model.Remark;
            parameters[8].Value  = model.State;
            parameters[9].Value  = model.InfoTime;
            parameters[10].Value = model.Id;

            int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemplo n.º 4
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public SteelManagement.Model.SteelInfo DataRowToModel(DataRow row)
 {
     SteelManagement.Model.SteelInfo model = new SteelManagement.Model.SteelInfo();
     if (row != null)
     {
         if (row["Id"] != null && row["Id"].ToString() != "")
         {
             model.Id = int.Parse(row["Id"].ToString());
         }
         if (row["EntryTime"] != null && row["EntryTime"].ToString() != "")
         {
             model.EntryTime = DateTime.Parse(row["EntryTime"].ToString());
         }
         if (row["Name"] != null)
         {
             model.Name = row["Name"].ToString();
         }
         if (row["Size"] != null)
         {
             model.Size = row["Size"].ToString();
         }
         if (row["Texture"] != null)
         {
             model.Texture = row["Texture"].ToString();
         }
         if (row["ProducePlace"] != null)
         {
             model.ProducePlace = row["ProducePlace"].ToString();
         }
         if (row["Price"] != null && row["Price"].ToString() != "")
         {
             model.Price = decimal.Parse(row["Price"].ToString());
         }
         if (row["Fluctuation"] != null && row["Fluctuation"].ToString() != "")
         {
             model.Fluctuation = decimal.Parse(row["Fluctuation"].ToString());
         }
         if (row["Remark"] != null)
         {
             model.Remark = row["Remark"].ToString();
         }
         if (row["State"] != null)
         {
             model.State = row["State"].ToString();
         }
         if (row["InfoTime"] != null && row["InfoTime"].ToString() != "")
         {
             model.InfoTime = DateTime.Parse(row["InfoTime"].ToString());
         }
     }
     return(model);
 }
Exemplo n.º 5
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(SteelManagement.Model.SteelInfo model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into SteelInfo(");
            strSql.Append("EntryTime,Name,Size,Texture,ProducePlace,Price,Fluctuation,Remark,State,InfoTime)");
            strSql.Append(" values (");
            strSql.Append("@EntryTime,@Name,@Size,@Texture,@ProducePlace,@Price,@Fluctuation,@Remark,@State,@InfoTime)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@EntryTime",    SqlDbType.DateTime),
                new SqlParameter("@Name",         SqlDbType.VarChar,   50),
                new SqlParameter("@Size",         SqlDbType.VarChar,   50),
                new SqlParameter("@Texture",      SqlDbType.VarChar,   50),
                new SqlParameter("@ProducePlace", SqlDbType.VarChar,   50),
                new SqlParameter("@Price",        SqlDbType.Money,      8),
                new SqlParameter("@Fluctuation",  SqlDbType.Money,      8),
                new SqlParameter("@Remark",       SqlDbType.VarChar,   50),
                new SqlParameter("@State",        SqlDbType.VarChar,   50),
                new SqlParameter("@InfoTime",     SqlDbType.DateTime)
            };
            parameters[0].Value = model.EntryTime;
            parameters[1].Value = model.Name;
            parameters[2].Value = model.Size;
            parameters[3].Value = model.Texture;
            parameters[4].Value = model.ProducePlace;
            parameters[5].Value = model.Price;
            parameters[6].Value = model.Fluctuation;
            parameters[7].Value = model.Remark;
            parameters[8].Value = model.State;
            parameters[9].Value = model.InfoTime;

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

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
Exemplo n.º 6
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public SteelManagement.Model.SteelInfo GetModel(int Id)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 Id,EntryTime,Name,Size,Texture,ProducePlace,Price,Fluctuation,Remark,State,InfoTime from SteelInfo ");
            strSql.Append(" where Id=@Id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@Id", SqlDbType.Int, 4)
            };
            parameters[0].Value = Id;

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

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }
Exemplo n.º 7
0
 private void btnOK_Click(object sender, EventArgs e)
 {
     if (_is4Modify)
     {
         try
         {
             _model.Name         = txtName.Text;
             _model.Size         = txtSize.Text;
             _model.Texture      = txtTexture.Text;
             _model.ProducePlace = txtProducePlace.Text;
             _model.Price        = decimal.Parse(txtPrice.Text);
             _model.Fluctuation  = decimal.Parse(txtFluctuation.Text);
             _model.Remark       = txtRemark.Text;
             _model.State        = txtState.Text;
             _model.InfoTime     = DateTime.Parse(txtInfoTime.Text);
             if (!_bllSteelInfo.Update(_model))
             {
                 MessageBoxEx.Show("更新失败,请稍后重试!");
                 return;
             }
             MessageBoxEx.Show("更新成功!");
             _updateDel(_curPage);
             this.DialogResult = DialogResult.OK;
             this.Close();
         }
         catch (Exception)
         {
             MessageBoxEx.Show("请检查输入是否有误,价格为0请填入0!");
             //throw;
         }
     }
     else
     {
         SteelManagement.Model.SteelInfo model = new SteelManagement.Model.SteelInfo();
         try
         {
             model.Name         = txtName.Text;                    model.Size = txtSize.Text;
             model.Texture      = txtTexture.Text;
             model.ProducePlace = txtProducePlace.Text;
             model.Price        = decimal.Parse(txtPrice.Text);
             model.Fluctuation  = decimal.Parse(txtFluctuation.Text);
             model.Remark       = txtRemark.Text;
             model.State        = txtState.Text;
             model.InfoTime     = DateTime.Parse(txtInfoTime.Text);
             model.EntryTime    = DateTime.Now;
             if (_bllSteelInfo.Add(model) <= 0)
             {
                 MessageBoxEx.Show("添加失败,请稍后重试!");
                 return;
             }
             MessageBoxEx.Show("添加成功");
             _updateDel(_curPage);
             this.DialogResult = DialogResult.OK;
             this.Close();
         }
         catch (Exception)
         {
             MessageBoxEx.Show("请检查输入是否有误,价格为0请填入0!");
             //throw;
         }
     }
 }