Exemple #1
0
        /// <summary>
        /// 增加一条记录
        /// </summary>
        /// <param name="_model"></param>
        /// <returns></returns>
        public int Add(FishEntity.InquiryEntity _model)
        {
            StringBuilder strSql = new StringBuilder( );

            strSql.Append("INSERT INTO t_inquiry (");
            strSql.Append("code,weight,number,remark,exchangerate,rmb,dollarprice,datetime)");
            strSql.Append(" VALUES (");
            strSql.Append("@code,@weight,@number,@remark,@exchangerate,@rmb,@dollarprice,@datetime);");
            strSql.Append("select last_insert_id();");
            MySqlParameter [] parameter =
            {
                new MySqlParameter("@code",         MySqlDbType.VarChar,  45),
                new MySqlParameter("@weight",       MySqlDbType.Decimal,  11),
                new MySqlParameter("@number",       MySqlDbType.Int32,    11),
                new MySqlParameter("@remark",       MySqlDbType.VarChar, 500),
                new MySqlParameter("@exchangerate", MySqlDbType.Decimal,  11),
                new MySqlParameter("@rmb",          MySqlDbType.Decimal,  11),
                new MySqlParameter("@dollarprice",  MySqlDbType.Decimal,  11),
                new MySqlParameter("@datetime",     MySqlDbType.DateTime)
            };
            parameter [0].Value = _model.Code;
            parameter [1].Value = _model.Weight;
            parameter [2].Value = _model.Number;
            parameter [3].Value = _model.Remark;
            parameter [4].Value = _model.Exchangerate;
            parameter [5].Value = _model.Rmb;
            parameter [6].Value = _model.Dollarprice;
            parameter [7].Value = _model.Datetime;

            int id = MySqlHelper.ExecuteSqlReturnId(strSql.ToString( ), parameter);

            return(id);
        }
Exemple #2
0
        /// <summary>
        /// 编辑一条记录
        /// </summary>
        /// <param name="_model"></param>
        /// <returns></returns>
        public bool Update(FishEntity.InquiryEntity _model)
        {
            StringBuilder strSql = new StringBuilder( );

            strSql.Append("UPDATE t_inquiry SET ");
            strSql.Append("code=@code,");
            strSql.Append("weight=@weight,");
            strSql.Append("number=@number,");
            strSql.Append("remark=@remark,");
            strSql.Append("exchangerate=@exchangerate,");
            strSql.Append("rmb=@rmb,");
            strSql.Append("dollarprice=@dollarprice,");
            strSql.Append("datetime=@datetime");
            strSql.Append(" WHERE id=@id");
            MySqlParameter [] parameter =
            {
                new MySqlParameter("@code",         MySqlDbType.VarChar,    45),
                new MySqlParameter("@weight",       MySqlDbType.Decimal,    11),
                new MySqlParameter("@number",       MySqlDbType.Int32,      11),
                new MySqlParameter("@remark",       MySqlDbType.VarChar,   500),
                new MySqlParameter("@exchangerate", MySqlDbType.Decimal,    11),
                new MySqlParameter("@rmb",          MySqlDbType.Decimal,    11),
                new MySqlParameter("@dollarprice",  MySqlDbType.Decimal,    11),
                new MySqlParameter("@datetime",     MySqlDbType.DateTime),
                new MySqlParameter("@id",           MySqlDbType.Int32, 11)
            };
            parameter [0].Value = _model.Code;
            parameter [1].Value = _model.Weight;
            parameter [2].Value = _model.Number;
            parameter [3].Value = _model.Remark;
            parameter [4].Value = _model.Exchangerate;
            parameter [5].Value = _model.Rmb;
            parameter [6].Value = _model.Dollarprice;
            parameter [7].Value = _model.Datetime;
            parameter [8].Value = _model.ID;

            int row = MySqlHelper.ExecuteSql(strSql.ToString( ), parameter);

            if (row > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemple #3
0
        /// <summary>
        /// 获取一个实体对象
        /// </summary>
        /// <param name="row"></param>
        /// <returns></returns>
        public FishEntity.InquiryEntity GetRowToModel(DataRow row)
        {
            FishEntity.InquiryEntity _model = new FishEntity.InquiryEntity( );

            if (row != null)
            {
                if (row ["id"] != null && row ["id"].ToString( ) != "")
                {
                    _model.ID = int.Parse(row ["id"].ToString( ));
                }
                if (row ["code"] != null && row ["code"].ToString( ) != "")
                {
                    _model.Code = row ["code"].ToString( );
                }
                if (row ["weight"] != null && row ["weight"].ToString( ) != "")
                {
                    _model.Weight = decimal.Parse(row ["weight"].ToString( ));
                }
                if (row ["number"] != null && row ["number"].ToString( ) != "")
                {
                    _model.Number = int.Parse(row ["number"].ToString( ));
                }
                if (row ["remark"] != null && row ["remark"].ToString( ) != "")
                {
                    _model.Remark = row ["remark"].ToString( );
                }
                if (row ["exchangerate"] != null && row ["exchangerate"].ToString( ) != "")
                {
                    _model.Exchangerate = decimal.Parse(row ["exchangerate"].ToString( ));
                }
                if (row ["rmb"] != null && row ["rmb"].ToString( ) != "")
                {
                    _model.Rmb = decimal.Parse(row ["rmb"].ToString( ));
                }
                if (row ["dollarprice"] != null && row ["dollarprice"].ToString( ) != "")
                {
                    _model.Dollarprice = decimal.Parse(row ["dollarprice"].ToString( ));
                }
                if (row ["datetime"] != null && row ["datetime"].ToString( ) != "")
                {
                    _model.Datetime = DateTime.Parse(row ["datetime"].ToString( ));
                }
            }

            return(_model);
        }
Exemple #4
0
        private void butOk_Click(object sender, EventArgs e)
        {
            if (Check( ) == false)
            {
                this.DialogResult = System.Windows.Forms.DialogResult.None;
                return;
            }
            bool isAdd = false;

            if (_model == null)
            {
                _model = new FishEntity.InquiryEntity( );
                isAdd  = true;
            }

            _model.Code         = texWeight.Tag.ToString( );
            _model.Weight       = string.IsNullOrEmpty(texWeight.Text) == true ? 0 : Convert.ToDecimal(texWeight.Text);
            _model.Number       = string.IsNullOrEmpty(texNumber.Text) == true ? 0 : Convert.ToInt32(texNumber.Text);
            _model.Exchangerate = string.IsNullOrEmpty(texExchangerate.Text) == true ? 0 : Convert.ToDecimal(texExchangerate.Text);
            _model.Rmb          = string.IsNullOrEmpty(texRmb.Text) == true ? 0 : Convert.ToDecimal(texRmb.Text);
            _model.Dollarprice  = string.IsNullOrEmpty(texDollarprice.Text) == true ? 0 : Convert.ToDecimal(texDollarprice.Text);
            _model.Datetime     = dateTimeP.Value;
            _model.Remark       = richRemark.Text;

            if (isAdd)
            {
                FishBll.Bll.InquiryBll _bll = new FishBll.Bll.InquiryBll( );
                int id = _bll.Add(_model);
                if (id > 0)
                {
                    OnRefresh( );
                }
            }
            else
            {
                FishBll.Bll.InquiryBll _bll = new FishBll.Bll.InquiryBll( );
                bool isOk = _bll.Update(_model);
                if (isOk)
                {
                    OnRefresh( );
                }
            }

            this.Close( );
        }
Exemple #5
0
        /// <summary>
        /// 获取数据列表
        /// </summary>
        /// <param name="dt"></param>
        /// <returns></returns>
        public List <FishEntity.InquiryEntity> GetDataTableToList(DataTable dt)
        {
            List <FishEntity.InquiryEntity> _modelList = new List <FishEntity.InquiryEntity> ( );
            int rowcount = dt.Rows.Count;

            if (rowcount > 0)
            {
                FishEntity.InquiryEntity _model = null;
                for (int i = 0; i < rowcount; i++)
                {
                    _model = _dao.GetRowToModel(dt.Rows [i]);
                    if (_model != null)
                    {
                        _modelList.Add(_model);
                    }
                }
            }

            return(_modelList);
        }
Exemple #6
0
        public FromInquirySet(string title, FishEntity.InquiryEntity entity, string fishId)
        {
            InitializeComponent( );

            _model = entity;
            if (_model != null)
            {
                texWeight.Text       = _model.Weight.ToString( );
                texNumber.Text       = _model.Number.ToString( );
                texRmb.Text          = _model.Rmb.ToString( );
                texExchangerate.Text = _model.Exchangerate.ToString( );
                texDollarprice.Text  = _model.Dollarprice.ToString( );
                if (_model.Datetime > DateTime.MinValue && _model.Datetime < DateTime.MaxValue)
                {
                    dateTimeP.Value = _model.Datetime;
                }
                richRemark.Text = _model.Remark;
            }
            texWeight.Tag = fishId;
            this.Text     = title;
        }
Exemple #7
0
        public override int Modify( )
        {
            if (dataGridView1.CurrentCell == null)
            {
                MessageBox.Show("请选择要编辑的行");
                return(0);
            }
            FishEntity.InquiryEntity entity = dataGridView1.CurrentRow.DataBoundItem as FishEntity.InquiryEntity;
            if (entity == null)
            {
                MessageBox.Show("请选择需要编辑的行");
                return(0);
            }

            FromInquirySet inven = new FromInquirySet("编辑数据", entity, codenum);

            inven.RefreshEvent += form_RefreshEvent;
            inven.ShowDialog( );

            return(0);
        }
Exemple #8
0
 /// <summary>
 /// 编辑一条记录
 /// </summary>
 /// <param name="_model"></param>
 /// <returns></returns>
 public bool Update(FishEntity.InquiryEntity _model)
 {
     return(_dao.Update(_model));
 }
Exemple #9
0
 /// <summary>
 /// 增加一条记录
 /// </summary>
 /// <param name="_model"></param>
 /// <returns></returns>
 public int Add(FishEntity.InquiryEntity _model)
 {
     return(_dao.Add(_model));
 }