Esempio n. 1
0
        protected void QueryOne(string operate, string orderBy)
        {
            errorProvider1.Clear();
            string whereEx = string.Empty;

            if (string.IsNullOrEmpty(_where))
            {
                whereEx = " 1=1 ";
            }
            else
            {
                whereEx = _where;
            }

            if (_entity != null)
            {
                whereEx += " and code " + operate + _entity.code;
            }

            List <FishEntity.CheckEntity> list = _bll.GetModelList(whereEx + orderBy);

            if (list == null || list.Count < 1)
            {
                MessageBox.Show("已经没有记录了!");
                return;
            }

            _entity = list[0];

            SetEntity();
            SetDetail();
        }
Esempio n. 2
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(FishEntity.CheckEntity model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update t_check set ");
            strSql.Append("code=@code,");
            strSql.Append("checkunitid=@checkunitid,");
            strSql.Append("checkunitcode=@checkunitcode,");
            strSql.Append("checkunit=@checkunit,");
            strSql.Append("checkfee=@checkfee,");
            strSql.Append("productid=@productid,");
            strSql.Append("productcode=@productcode,");
            strSql.Append("productname=@productname,");
            strSql.Append("remark=@remark,");
            strSql.Append("modifyman=@modifyman,");
            strSql.Append("modifytime=@modifytime");
            strSql.Append(" where id=@id");
            MySqlParameter[] parameters =
            {
                new MySqlParameter("@code",          MySqlDbType.VarChar,     20),
                new MySqlParameter("@checkunitid",   MySqlDbType.Int32,        8),
                new MySqlParameter("@checkunitcode", MySqlDbType.VarChar,     45),
                new MySqlParameter("@checkunit",     MySqlDbType.VarChar,    100),
                new MySqlParameter("@checkfee",      MySqlDbType.Decimal,     12),
                new MySqlParameter("@productid",     MySqlDbType.Int32,       11),
                new MySqlParameter("@productcode",   MySqlDbType.VarChar,     45),
                new MySqlParameter("@productname",   MySqlDbType.VarChar,     50),
                new MySqlParameter("@remark",        MySqlDbType.VarChar,    255),
                new MySqlParameter("@modifyman",     MySqlDbType.VarChar,     45),
                new MySqlParameter("@modifytime",    MySqlDbType.Timestamp),
                new MySqlParameter("@id",            MySqlDbType.Int32, 11)
            };
            parameters[0].Value  = model.code;
            parameters[1].Value  = model.checkunitid;
            parameters[2].Value  = model.checkunitcode;
            parameters[3].Value  = model.checkunit;
            parameters[4].Value  = model.checkfee;
            parameters[5].Value  = model.productid;
            parameters[6].Value  = model.productcode;
            parameters[7].Value  = model.productname;
            parameters[8].Value  = model.remark;
            parameters[9].Value  = model.modifyman;
            parameters[10].Value = model.modifytime;
            parameters[11].Value = model.id;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Esempio n. 3
0
 protected void ClearText()
 {
     errorProvider1.Clear();
     txtCode.Text          = string.Empty;
     txtCheckUnit.Text     = string.Empty;
     txtCheckUnitCode.Text = string.Empty;
     txtCheckUnitCode.Tag  = string.Empty;
     txtFishCode.Text      = string.Empty;
     txtFishCode.Tag       = string.Empty;
     txtFishName.Text      = string.Empty;
     txtCheckFee.Text      = string.Empty;
     dtpCheckDate.Value    = DateTime.Now;
     dataGridView1.Rows.Clear();
     _entity = null;
 }
Esempio n. 4
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(FishEntity.CheckEntity model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into t_check(");
            strSql.Append("code,checkdate,checkunitid,checkunitcode,checkunit,checkfee,productid,productcode,productname,remark,createman,createtime,modifyman,modifytime)");
            strSql.Append(" values (");
            strSql.Append("@code,@checkdate,@checkunitid,@checkunitcode,@checkunit,@checkfee,@productid,@productcode,@productname,@remark,@createman,@createtime,@modifyman,@modifytime);");
            strSql.Append("select LAST_INSERT_ID();");

            MySqlParameter[] parameters =
            {
                new MySqlParameter("@code",          MySqlDbType.VarChar,     20),
                new MySqlParameter("@checkdate",     MySqlDbType.Timestamp),
                new MySqlParameter("@checkunitid",   MySqlDbType.Int32,        8),
                new MySqlParameter("@checkunitcode", MySqlDbType.VarChar,     45),
                new MySqlParameter("@checkunit",     MySqlDbType.VarChar,    100),
                new MySqlParameter("@checkfee",      MySqlDbType.Decimal,     12),
                new MySqlParameter("@productid",     MySqlDbType.Int32,       11),
                new MySqlParameter("@productcode",   MySqlDbType.VarChar,     45),
                new MySqlParameter("@productname",   MySqlDbType.VarChar,     50),
                new MySqlParameter("@remark",        MySqlDbType.VarChar,    255),
                new MySqlParameter("@createman",     MySqlDbType.VarChar,     45),
                new MySqlParameter("@createtime",    MySqlDbType.Timestamp),
                new MySqlParameter("@modifyman",     MySqlDbType.VarChar,     45),
                new MySqlParameter("@modifytime",    MySqlDbType.Timestamp)
            };
            parameters[0].Value  = model.code;
            parameters[1].Value  = model.checkdate;
            parameters[2].Value  = model.checkunitid;
            parameters[3].Value  = model.checkunitcode;
            parameters[4].Value  = model.checkunit;
            parameters[5].Value  = model.checkfee;
            parameters[6].Value  = model.productid;
            parameters[7].Value  = model.productcode;
            parameters[8].Value  = model.productname;
            parameters[9].Value  = model.remark;
            parameters[10].Value = model.createman;
            parameters[11].Value = model.createtime;
            parameters[12].Value = model.modifyman;
            parameters[13].Value = model.modifytime;

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

            return(id);
        }
Esempio n. 5
0
        public override void Save()
        {
            if (Check() == false)
            {
                return;
            }
            _entity = new FishEntity.CheckEntity();

            GetEntity();

            _entity.createman  = FishEntity.Variable.User.username;
            _entity.createtime = DateTime.Now;
            _entity.modifyman  = _entity.createman;
            _entity.modifytime = _entity.createtime;

            _entity.code = FishBll.Bll.SequenceUtil.GetCheckSequence();
            while (_bll.Exists(_entity.code))
            {
                _entity.code = FishBll.Bll.SequenceUtil.GetCheckSequence();
            }
            int id = _bll.Add(_entity);

            if (id > 0)
            {
                AddDetails(id, true);

                _entity.id   = id;
                txtCode.Text = _entity.code;

                tmiCancel.Visible   = false;
                tmiSave.Visible     = false;
                tmiAdd.Visible      = true;
                tmiModify.Visible   = true;
                tmiQuery.Visible    = true;
                tmiPrevious.Visible = true;
                tmiNext.Visible     = true;
                tmiDelete.Visible   = true;

                MessageBox.Show("新增成功。");
            }
            else
            {
                MessageBox.Show("新增失败。");
            }
        }
Esempio n. 6
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public FishEntity.CheckEntity GetModel(int id)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select id,code,checkdate,checkunitid,checkunitcode,checkunit,checkfee,productid,productcode,productname,remark,createman,createtime,modifyman,modifytime from t_check ");
            strSql.Append(" where id=@id");
            MySqlParameter[] parameters =
            {
                new MySqlParameter("@id", MySqlDbType.Int32)
            };
            parameters[0].Value = id;

            FishEntity.CheckEntity model = new FishEntity.CheckEntity();
            DataSet ds = MySqlHelper.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }
Esempio n. 7
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public FishEntity.CheckEntity DataRowToModel(DataRow row)
 {
     FishEntity.CheckEntity model = new FishEntity.CheckEntity();
     if (row != null)
     {
         if (row["id"] != null && row["id"].ToString() != "")
         {
             model.id = int.Parse(row["id"].ToString());
         }
         if (row["code"] != null)
         {
             model.code = row["code"].ToString();
         }
         if (row["checkdate"] != null && row["checkdate"].ToString() != "")
         {
             model.checkdate = DateTime.Parse(row["checkdate"].ToString());
         }
         if (row["checkunitid"] != null && row["checkunitid"].ToString() != "")
         {
             model.checkunitid = int.Parse(row["checkunitid"].ToString());
         }
         if (row["checkunitcode"] != null)
         {
             model.checkunitcode = row["checkunitcode"].ToString();
         }
         if (row["checkunit"] != null)
         {
             model.checkunit = row["checkunit"].ToString();
         }
         if (row["checkfee"] != null && row["checkfee"].ToString() != "")
         {
             model.checkfee = decimal.Parse(row["checkfee"].ToString());
         }
         if (row["productid"] != null && row["productid"].ToString() != "")
         {
             model.productid = int.Parse(row["productid"].ToString());
         }
         if (row["productcode"] != null)
         {
             model.productcode = row["productcode"].ToString();
         }
         if (row["productname"] != null)
         {
             model.productname = row["productname"].ToString();
         }
         if (row["remark"] != null)
         {
             model.remark = row["remark"].ToString();
         }
         if (row["createman"] != null)
         {
             model.createman = row["createman"].ToString();
         }
         if (row["createtime"] != null && row["createtime"].ToString() != "")
         {
             model.createtime = DateTime.Parse(row["createtime"].ToString());
         }
         if (row["modifyman"] != null)
         {
             model.modifyman = row["modifyman"].ToString();
         }
         if (row["modifytime"] != null && row["modifytime"].ToString() != "")
         {
             model.modifytime = DateTime.Parse(row["modifytime"].ToString());
         }
     }
     return(model);
 }
Esempio n. 8
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public bool Update(FishEntity.CheckEntity model)
 {
     return(dal.Update(model));
 }
Esempio n. 9
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public int Add(FishEntity.CheckEntity model)
 {
     return(dal.Add(model));
 }