Ejemplo n.º 1
0
 public FrmAddSaleBill(Action <int> updateDel, int curPage, SteelManagement.Model.SaleInfo model)
 {
     this.StartPosition = FormStartPosition.CenterParent;
     InitializeComponent();
     _updateDel     = updateDel;
     _curPage       = curPage;
     _saleInfoModel = model;
 }
Ejemplo n.º 2
0
 public FrmAddSaleInfo(Action <int> updateDel, int curPage, bool is4Modify = false, SteelManagement.Model.SaleInfo model = null)
 {
     this.StartPosition = FormStartPosition.CenterParent;
     InitializeComponent();
     _updateDel = updateDel;
     _curPage   = curPage;
     _is4Modify = is4Modify;
     _model     = model;
 }
Ejemplo n.º 3
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public SteelManagement.Model.SaleInfo GetModel(int Id)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 Id,EntryTime,JianChiLv,ArrivalTime,SettleTime,Supplier,Brand,TransportWay,Size,Texture,Amount,Margin,OnlinePrice,Fluctuation1,Fluctuation2,SalePrice,TotalSale,MarginRate,SerialNo,OperatorId,Corporation,Project,LiXi,TieXi from SaleInfo ");
            strSql.Append(" where Id=@Id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@Id", SqlDbType.Int, 4)
            };
            parameters[0].Value = Id;

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

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }
Ejemplo n.º 4
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            if (_is4Modify)
            {
                try
                {
                    _model.Corporation = txtCorporation.Text;
                    if (string.IsNullOrEmpty(txtProject.Text))
                    {
                        MessageBoxEx.Show("项目名称不能为空!");
                        return;
                    }
                    _model.Project = txtProject.Text;
                    _model.TieXi   = DecimalHandler.Parse(txtTieXi.Text);
                    _model.LiXi    = DecimalHandler.Parse(txtLiXi.Text);

                    _model.JianChiLv    = DecimalHandler.Parse(txtJianChiLv.Text);
                    _model.ArrivalTime  = DateTime.Parse(txtArrivalTime.Text);
                    _model.SettleTime   = DateTime.Parse(txtSettleTime.Text);
                    _model.Supplier     = txtSupplier.Text;
                    _model.Brand        = txtBrand.Text;
                    _model.TransportWay = txtTransportWay.Text;
                    _model.Size         = txtSize.Text;
                    _model.Texture      = txtTexture.Text;
                    _model.Amount       = DecimalHandler.Parse(txtAmount.Text);
                    _model.Margin       = DecimalHandler.Parse(txtMargin.Text);
                    _model.OnlinePrice  = DecimalHandler.Parse(txtOnlinePrice.Text);
                    _model.Fluctuation1 = DecimalHandler.Parse(txtFluctuation1.Text);
                    _model.Fluctuation2 = DecimalHandler.Parse(txtFluctuation2.Text);
                    _model.SalePrice    = DecimalHandler.Parse(txtSalePrice.Text);
                    _model.TotalSale    = DecimalHandler.Parse(txtTotalSale.Text);
                    _model.MarginRate   = DecimalHandler.Parse(txtMarginRate.Text);
                    if (!_bllSaleInfo.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.SaleInfo model = new SteelManagement.Model.SaleInfo();
                try
                {
                    model.Corporation = txtCorporation.Text;
                    if (string.IsNullOrEmpty(txtProject.Text))
                    {
                        MessageBoxEx.Show("项目名称不能为空!");
                        return;
                    }
                    model.Project = txtProject.Text;
                    model.TieXi   = DecimalHandler.Parse(txtTieXi.Text);
                    model.LiXi    = DecimalHandler.Parse(txtLiXi.Text);

                    model.JianChiLv    = DecimalHandler.Parse(txtJianChiLv.Text);
                    model.ArrivalTime  = DateTime.Parse(txtArrivalTime.Text);
                    model.SettleTime   = DateTime.Parse(txtSettleTime.Text);
                    model.Supplier     = txtSupplier.Text;
                    model.Brand        = txtBrand.Text;
                    model.TransportWay = txtTransportWay.Text;
                    model.Size         = txtSize.Text;
                    model.Texture      = txtTexture.Text;
                    model.Amount       = DecimalHandler.Parse(txtAmount.Text);
                    model.Margin       = DecimalHandler.Parse(txtMargin.Text);
                    model.OnlinePrice  = DecimalHandler.Parse(txtOnlinePrice.Text);
                    model.Fluctuation1 = DecimalHandler.Parse(txtFluctuation1.Text);
                    model.Fluctuation2 = DecimalHandler.Parse(txtFluctuation2.Text);
                    model.SalePrice    = DecimalHandler.Parse(txtSalePrice.Text);
                    model.TotalSale    = DecimalHandler.Parse(txtTotalSale.Text);
                    model.MarginRate   = DecimalHandler.Parse(txtMarginRate.Text);
                    model.EntryTime    = DateTime.Now;
                    model.SerialNo     = SerialNoGenerator.GetSerialNo(SerialNoGenerator.Type.Type02Sale);
                    model.OperatorId   = GlobalUtils.LoginUser.Id;
                    if (_bllSaleInfo.Add(model) <= 0)
                    {
                        MessageBoxEx.Show("添加失败,请稍后重试!");
                        return;
                    }
                    MessageBoxEx.Show("添加成功");
                    _updateDel(_curPage);
                    this.DialogResult = DialogResult.OK;
                    this.Close();
                }
                catch (Exception)
                {
                    MessageBoxEx.Show("请检查输入是否有误,价格为0请填入0!");
                    //throw;
                }
            }
        }
Ejemplo n.º 5
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(SteelManagement.Model.SaleInfo model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into SaleInfo(");
            strSql.Append("EntryTime,JianChiLv,ArrivalTime,SettleTime,Supplier,Brand,TransportWay,Size,Texture,Amount,Margin,OnlinePrice,Fluctuation1,Fluctuation2,SalePrice,TotalSale,MarginRate,SerialNo,OperatorId,Corporation,Project,LiXi,TieXi)");
            strSql.Append(" values (");
            strSql.Append("@EntryTime,@JianChiLv,@ArrivalTime,@SettleTime,@Supplier,@Brand,@TransportWay,@Size,@Texture,@Amount,@Margin,@OnlinePrice,@Fluctuation1,@Fluctuation2,@SalePrice,@TotalSale,@MarginRate,@SerialNo,@OperatorId,@Corporation,@Project,@LiXi,@TieXi)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@EntryTime",    SqlDbType.DateTime),
                new SqlParameter("@JianChiLv",    SqlDbType.Money,      8),
                new SqlParameter("@ArrivalTime",  SqlDbType.DateTime,   3),
                new SqlParameter("@SettleTime",   SqlDbType.DateTime,   3),
                new SqlParameter("@Supplier",     SqlDbType.VarChar,   50),
                new SqlParameter("@Brand",        SqlDbType.VarChar,   50),
                new SqlParameter("@TransportWay", SqlDbType.VarChar,   50),
                new SqlParameter("@Size",         SqlDbType.VarChar,   50),
                new SqlParameter("@Texture",      SqlDbType.VarChar,   50),
                new SqlParameter("@Amount",       SqlDbType.Money,      8),
                new SqlParameter("@Margin",       SqlDbType.Money,      8),
                new SqlParameter("@OnlinePrice",  SqlDbType.Money,      8),
                new SqlParameter("@Fluctuation1", SqlDbType.Money,      8),
                new SqlParameter("@Fluctuation2", SqlDbType.Money,      8),
                new SqlParameter("@SalePrice",    SqlDbType.Money,      8),
                new SqlParameter("@TotalSale",    SqlDbType.Money,      8),
                new SqlParameter("@MarginRate",   SqlDbType.Money,      8),
                new SqlParameter("@SerialNo",     SqlDbType.VarChar,   50),
                new SqlParameter("@OperatorId",   SqlDbType.Int,        4),
                new SqlParameter("@Corporation",  SqlDbType.VarChar,   50),
                new SqlParameter("@Project",      SqlDbType.VarChar,   50),
                new SqlParameter("@LiXi",         SqlDbType.Money,      8),
                new SqlParameter("@TieXi",        SqlDbType.Money, 8)
            };
            parameters[0].Value  = model.EntryTime;
            parameters[1].Value  = model.JianChiLv;
            parameters[2].Value  = model.ArrivalTime;
            parameters[3].Value  = model.SettleTime;
            parameters[4].Value  = model.Supplier;
            parameters[5].Value  = model.Brand;
            parameters[6].Value  = model.TransportWay;
            parameters[7].Value  = model.Size;
            parameters[8].Value  = model.Texture;
            parameters[9].Value  = model.Amount;
            parameters[10].Value = model.Margin;
            parameters[11].Value = model.OnlinePrice;
            parameters[12].Value = model.Fluctuation1;
            parameters[13].Value = model.Fluctuation2;
            parameters[14].Value = model.SalePrice;
            parameters[15].Value = model.TotalSale;
            parameters[16].Value = model.MarginRate;
            parameters[17].Value = model.SerialNo;
            parameters[18].Value = model.OperatorId;
            parameters[19].Value = model.Corporation;
            parameters[20].Value = model.Project;
            parameters[21].Value = model.LiXi;
            parameters[22].Value = model.TieXi;

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

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
Ejemplo n.º 6
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public SteelManagement.Model.SaleInfo DataRowToModel(DataRow row)
 {
     SteelManagement.Model.SaleInfo model = new SteelManagement.Model.SaleInfo();
     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["JianChiLv"] != null && row["JianChiLv"].ToString() != "")
         {
             model.JianChiLv = decimal.Parse(row["JianChiLv"].ToString());
         }
         if (row["ArrivalTime"] != null && row["ArrivalTime"].ToString() != "")
         {
             model.ArrivalTime = DateTime.Parse(row["ArrivalTime"].ToString());
         }
         if (row["SettleTime"] != null && row["SettleTime"].ToString() != "")
         {
             model.SettleTime = DateTime.Parse(row["SettleTime"].ToString());
         }
         if (row["Supplier"] != null)
         {
             model.Supplier = row["Supplier"].ToString();
         }
         if (row["Brand"] != null)
         {
             model.Brand = row["Brand"].ToString();
         }
         if (row["TransportWay"] != null)
         {
             model.TransportWay = row["TransportWay"].ToString();
         }
         if (row["Size"] != null)
         {
             model.Size = row["Size"].ToString();
         }
         if (row["Texture"] != null)
         {
             model.Texture = row["Texture"].ToString();
         }
         if (row["Amount"] != null && row["Amount"].ToString() != "")
         {
             model.Amount = decimal.Parse(row["Amount"].ToString());
         }
         if (row["Margin"] != null && row["Margin"].ToString() != "")
         {
             model.Margin = decimal.Parse(row["Margin"].ToString());
         }
         if (row["OnlinePrice"] != null && row["OnlinePrice"].ToString() != "")
         {
             model.OnlinePrice = decimal.Parse(row["OnlinePrice"].ToString());
         }
         if (row["Fluctuation1"] != null && row["Fluctuation1"].ToString() != "")
         {
             model.Fluctuation1 = decimal.Parse(row["Fluctuation1"].ToString());
         }
         if (row["Fluctuation2"] != null && row["Fluctuation2"].ToString() != "")
         {
             model.Fluctuation2 = decimal.Parse(row["Fluctuation2"].ToString());
         }
         if (row["SalePrice"] != null && row["SalePrice"].ToString() != "")
         {
             model.SalePrice = decimal.Parse(row["SalePrice"].ToString());
         }
         if (row["TotalSale"] != null && row["TotalSale"].ToString() != "")
         {
             model.TotalSale = decimal.Parse(row["TotalSale"].ToString());
         }
         if (row["MarginRate"] != null && row["MarginRate"].ToString() != "")
         {
             model.MarginRate = decimal.Parse(row["MarginRate"].ToString());
         }
         if (row["SerialNo"] != null)
         {
             model.SerialNo = row["SerialNo"].ToString();
         }
         if (row["OperatorId"] != null && row["OperatorId"].ToString() != "")
         {
             model.OperatorId = int.Parse(row["OperatorId"].ToString());
         }
         if (row["Corporation"] != null)
         {
             model.Corporation = row["Corporation"].ToString();
         }
         if (row["Project"] != null)
         {
             model.Project = row["Project"].ToString();
         }
         if (row["LiXi"] != null && row["LiXi"].ToString() != "")
         {
             model.LiXi = decimal.Parse(row["LiXi"].ToString());
         }
         if (row["TieXi"] != null && row["TieXi"].ToString() != "")
         {
             model.TieXi = decimal.Parse(row["TieXi"].ToString());
         }
     }
     return(model);
 }
Ejemplo n.º 7
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(SteelManagement.Model.SaleInfo model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update SaleInfo set ");
            strSql.Append("EntryTime=@EntryTime,");
            strSql.Append("JianChiLv=@JianChiLv,");
            strSql.Append("ArrivalTime=@ArrivalTime,");
            strSql.Append("SettleTime=@SettleTime,");
            strSql.Append("Supplier=@Supplier,");
            strSql.Append("Brand=@Brand,");
            strSql.Append("TransportWay=@TransportWay,");
            strSql.Append("Size=@Size,");
            strSql.Append("Texture=@Texture,");
            strSql.Append("Amount=@Amount,");
            strSql.Append("Margin=@Margin,");
            strSql.Append("OnlinePrice=@OnlinePrice,");
            strSql.Append("Fluctuation1=@Fluctuation1,");
            strSql.Append("Fluctuation2=@Fluctuation2,");
            strSql.Append("SalePrice=@SalePrice,");
            strSql.Append("TotalSale=@TotalSale,");
            strSql.Append("MarginRate=@MarginRate,");
            strSql.Append("SerialNo=@SerialNo,");
            strSql.Append("OperatorId=@OperatorId,");
            strSql.Append("Corporation=@Corporation,");
            strSql.Append("Project=@Project,");
            strSql.Append("LiXi=@LiXi,");
            strSql.Append("TieXi=@TieXi");
            strSql.Append(" where Id=@Id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@EntryTime",    SqlDbType.DateTime),
                new SqlParameter("@JianChiLv",    SqlDbType.Money,      8),
                new SqlParameter("@ArrivalTime",  SqlDbType.DateTime,   3),
                new SqlParameter("@SettleTime",   SqlDbType.DateTime,   3),
                new SqlParameter("@Supplier",     SqlDbType.VarChar,   50),
                new SqlParameter("@Brand",        SqlDbType.VarChar,   50),
                new SqlParameter("@TransportWay", SqlDbType.VarChar,   50),
                new SqlParameter("@Size",         SqlDbType.VarChar,   50),
                new SqlParameter("@Texture",      SqlDbType.VarChar,   50),
                new SqlParameter("@Amount",       SqlDbType.Money,      8),
                new SqlParameter("@Margin",       SqlDbType.Money,      8),
                new SqlParameter("@OnlinePrice",  SqlDbType.Money,      8),
                new SqlParameter("@Fluctuation1", SqlDbType.Money,      8),
                new SqlParameter("@Fluctuation2", SqlDbType.Money,      8),
                new SqlParameter("@SalePrice",    SqlDbType.Money,      8),
                new SqlParameter("@TotalSale",    SqlDbType.Money,      8),
                new SqlParameter("@MarginRate",   SqlDbType.Money,      8),
                new SqlParameter("@SerialNo",     SqlDbType.VarChar,   50),
                new SqlParameter("@OperatorId",   SqlDbType.Int,        4),
                new SqlParameter("@Corporation",  SqlDbType.VarChar,   50),
                new SqlParameter("@Project",      SqlDbType.VarChar,   50),
                new SqlParameter("@LiXi",         SqlDbType.Money,      8),
                new SqlParameter("@TieXi",        SqlDbType.Money,      8),
                new SqlParameter("@Id",           SqlDbType.Int, 4)
            };
            parameters[0].Value  = model.EntryTime;
            parameters[1].Value  = model.JianChiLv;
            parameters[2].Value  = model.ArrivalTime;
            parameters[3].Value  = model.SettleTime;
            parameters[4].Value  = model.Supplier;
            parameters[5].Value  = model.Brand;
            parameters[6].Value  = model.TransportWay;
            parameters[7].Value  = model.Size;
            parameters[8].Value  = model.Texture;
            parameters[9].Value  = model.Amount;
            parameters[10].Value = model.Margin;
            parameters[11].Value = model.OnlinePrice;
            parameters[12].Value = model.Fluctuation1;
            parameters[13].Value = model.Fluctuation2;
            parameters[14].Value = model.SalePrice;
            parameters[15].Value = model.TotalSale;
            parameters[16].Value = model.MarginRate;
            parameters[17].Value = model.SerialNo;
            parameters[18].Value = model.OperatorId;
            parameters[19].Value = model.Corporation;
            parameters[20].Value = model.Project;
            parameters[21].Value = model.LiXi;
            parameters[22].Value = model.TieXi;
            parameters[23].Value = model.Id;

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

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