protected void QueryOne(string operate, string orderBy) { 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.StorageBillsEntity> list = _bll.GetModelList(whereEx + orderBy); if (list == null || list.Count < 1) { MessageBox.Show("已经没有记录了!"); return; } _entity = list[0]; SetStorageBill(); }
public override int Query() { //TODO _entity = null; QueryOne(">", " order by id asc limit 1"); return(1); }
public override void Save() { if (Check() == false) { return; } _entity = new FishEntity.StorageBillsEntity(); GetStorageBills(); _entity.code = FishBll.Bll.SequenceUtil.GetStorageBillSequence(); while (_bll.Exists(_entity.code)) { _entity.code = FishBll.Bll.SequenceUtil.GetStorageBillSequence(); } _entity.createman = FishEntity.Variable.User.username; _entity.createtime = DateTime.Now; _entity.modifyman = _entity.createman; _entity.modifytime = _entity.createtime; int id = _bll.Add(_entity); if (id > 0) { _entity.id = id; txtCode.Text = _entity.code; //更新 鱼粉的状态为“自营”,重量,数量 FishBll.Bll.ProductBll productBll = new FishBll.Bll.ProductBll(); bool isok = productBll.UpdateState(_entity.productid.Value, FishEntity.Constant.STATE_SELFBUY, _entity.actualnumber.Value, _entity.tons.Value); //tmiSave.Visible = false; //tmiCancel.Visible = false; //tmiDelete.Visible = true; //tmiAdd.Visible = true; //tmiModify.Visible = true; //tmiQuery.Visible = true; //tmiPrevious.Visible = true; //tmiNext.Visible = true; ControlButtomRoles(); MessageBox.Show("新增成功。"); } else { MessageBox.Show("新增失败。"); } }
protected void ClearText() { errorProvider1.Clear(); txtCode.Text = string.Empty; txtCompanyCode.Text = string.Empty; txtCompanyCode.Tag = string.Empty; txtCompanyName.Text = string.Empty; txtFishCode.Text = string.Empty; txtFishCode.Tag = string.Empty; txtFishName.Text = string.Empty; txtlocation.Text = string.Empty; txtNumber.Text = string.Empty; txtOperateCode.Text = string.Empty; txtPlace.Text = string.Empty; txtRemark.Text = string.Empty; txtStorageBill.Text = string.Empty; txtTon.Text = string.Empty; dtpunboxdate.Value = DateTime.Now; txtShipno.Text = string.Empty; _entity = null; }
/// <summary> /// 得到一个对象实体 /// </summary> public FishEntity.StorageBillsEntity GetModel(int id) { StringBuilder strSql = new StringBuilder(); strSql.Append("select id,code,operatecode,delegateunitid,delegateunitcode,delegateunit,deliverybills,productid,productcode,productname,unboxdate,place,tons,number,actualnumber,remark,location,createtime,createman,modifyman,modifytime,isdelete,shipno from t_storagebills "); strSql.Append(" where id=@id"); MySqlParameter[] parameters = { new MySqlParameter("@id", MySqlDbType.Int32) }; parameters[0].Value = id; FishEntity.StorageBillsEntity model = new FishEntity.StorageBillsEntity(); DataSet ds = MySqlHelper.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { return(DataRowToModel(ds.Tables[0].Rows[0])); } else { return(null); } }
/// <summary> /// 增加一条数据 /// </summary> public int Add(FishEntity.StorageBillsEntity model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into t_storagebills("); strSql.Append("code,operatecode,delegateunitid,delegateunitcode,delegateunit,deliverybills,productid,productcode,productname,unboxdate,place,tons,number,actualnumber,remark,location,createtime,createman,modifyman,modifytime,isdelete,shipno)"); strSql.Append(" values ("); strSql.Append("@code,@operatecode,@delegateunitid,@delegateunitcode,@delegateunit,@deliverybills,@productid,@productcode,@productname,@unboxdate,@place,@tons,@number,@actualnumber,@remark,@location,@createtime,@createman,@modifyman,@modifytime,@isdelete,@shipno);"); strSql.Append("select LAST_INSERT_ID();"); MySqlParameter[] parameters = { new MySqlParameter("@code", MySqlDbType.VarChar, 45), new MySqlParameter("@operatecode", MySqlDbType.VarChar, 45), new MySqlParameter("@delegateunitid", MySqlDbType.Int32, 8), new MySqlParameter("@delegateunitcode", MySqlDbType.VarChar, 45), new MySqlParameter("@delegateunit", MySqlDbType.VarChar, 100), new MySqlParameter("@deliverybills", MySqlDbType.VarChar, 45), new MySqlParameter("@productid", MySqlDbType.Int32, 11), new MySqlParameter("@productcode", MySqlDbType.VarChar, 45), new MySqlParameter("@productname", MySqlDbType.VarChar, 50), new MySqlParameter("@unboxdate", MySqlDbType.Timestamp), new MySqlParameter("@place", MySqlDbType.VarChar, 100), new MySqlParameter("@tons", MySqlDbType.Decimal, 12), new MySqlParameter("@number", MySqlDbType.Int32, 11), new MySqlParameter("@actualnumber", MySqlDbType.Int32, 11), new MySqlParameter("@remark", MySqlDbType.VarChar, 200), new MySqlParameter("@location", MySqlDbType.VarChar, 200), new MySqlParameter("@createtime", MySqlDbType.Timestamp), new MySqlParameter("@createman", MySqlDbType.VarChar, 45), new MySqlParameter("@modifyman", MySqlDbType.VarChar, 45), new MySqlParameter("@modifytime", MySqlDbType.Timestamp), new MySqlParameter("@isdelete", MySqlDbType.UInt16, 2), new MySqlParameter("@shipno", MySqlDbType.VarChar, 45), }; parameters[0].Value = model.code; parameters[1].Value = model.operatecode; parameters[2].Value = model.delegateunitid; parameters[3].Value = model.delegateunitcode; parameters[4].Value = model.delegateunit; parameters[5].Value = model.deliverybills; parameters[6].Value = model.productid; parameters[7].Value = model.productcode; parameters[8].Value = model.productname; parameters[9].Value = model.unboxdate; parameters[10].Value = model.place; parameters[11].Value = model.tons; parameters[12].Value = model.number; parameters[13].Value = model.actualnumber; parameters[14].Value = model.remark; parameters[15].Value = model.location; parameters[16].Value = model.createtime; parameters[17].Value = model.createman; parameters[18].Value = model.modifyman; parameters[19].Value = model.modifytime; parameters[20].Value = model.isdelete; parameters[21].Value = model.shipno; int id = MySqlHelper.ExecuteSqlReturnId(strSql.ToString(), parameters); return(id); }
/// <summary> /// 得到一个对象实体 /// </summary> public FishEntity.StorageBillsEntity DataRowToModel(DataRow row) { FishEntity.StorageBillsEntity model = new FishEntity.StorageBillsEntity(); 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["operatecode"] != null) { model.operatecode = row["operatecode"].ToString(); } if (row["delegateunitid"] != null && row["delegateunitid"].ToString() != "") { model.delegateunitid = int.Parse(row["delegateunitid"].ToString()); } if (row["delegateunitcode"] != null) { model.delegateunitcode = row["delegateunitcode"].ToString(); } if (row["delegateunit"] != null) { model.delegateunit = row["delegateunit"].ToString(); } if (row["deliverybills"] != null) { model.deliverybills = row["deliverybills"].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["unboxdate"] != null && row["unboxdate"].ToString() != "") { model.unboxdate = DateTime.Parse(row["unboxdate"].ToString()); } if (row["place"] != null) { model.place = row["place"].ToString(); } if (row["tons"] != null && row["tons"].ToString() != "") { model.tons = decimal.Parse(row["tons"].ToString()); } if (row["number"] != null && row["number"].ToString() != "") { model.number = int.Parse(row["number"].ToString()); } if (row["actualnumber"] != null && row["actualnumber"].ToString() != "") { model.actualnumber = int.Parse(row["actualnumber"].ToString()); } if (row["remark"] != null) { model.remark = row["remark"].ToString(); } if (row["location"] != null) { model.location = row["location"].ToString(); } if (row["createtime"] != null && row["createtime"].ToString() != "") { model.createtime = DateTime.Parse(row["createtime"].ToString()); } if (row["createman"] != null) { model.createman = row["createman"].ToString(); } if (row["modifyman"] != null) { model.modifyman = row["modifyman"].ToString(); } if (row["modifytime"] != null && row["modifytime"].ToString() != "") { model.modifytime = DateTime.Parse(row["modifytime"].ToString()); } if (row["isdelete"] != null && row["isdelete"].ToString() != "") { model.isdelete = int.Parse(row["isdelete"].ToString()); } if (row["shipno"] != null) { model.shipno = row["shipno"].ToString(); } } return(model); }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(FishEntity.StorageBillsEntity model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update t_storagebills set "); strSql.Append("code=@code,"); strSql.Append("operatecode=@operatecode,"); strSql.Append("delegateunitid=@delegateunitid,"); strSql.Append("delegateunitcode=@delegateunitcode,"); strSql.Append("delegateunit=@delegateunit,"); strSql.Append("deliverybills=@deliverybills,"); strSql.Append("productid=@productid,"); strSql.Append("productcode=@productcode,"); strSql.Append("productname=@productname,"); strSql.Append("place=@place,"); strSql.Append("tons=@tons,"); strSql.Append("number=@number,"); strSql.Append("actualnumber=@actualnumber,"); strSql.Append("remark=@remark,"); strSql.Append("location=@location,"); strSql.Append("createman=@createman,"); strSql.Append("modifyman=@modifyman,"); strSql.Append("isdelete=@isdelete,"); strSql.Append("shipno=@shipno"); strSql.Append(" where id=@id"); MySqlParameter[] parameters = { new MySqlParameter("@code", MySqlDbType.VarChar, 45), new MySqlParameter("@operatecode", MySqlDbType.VarChar, 45), new MySqlParameter("@delegateunitid", MySqlDbType.Int32, 8), new MySqlParameter("@delegateunitcode", MySqlDbType.VarChar, 45), new MySqlParameter("@delegateunit", MySqlDbType.VarChar, 100), new MySqlParameter("@deliverybills", MySqlDbType.VarChar, 45), new MySqlParameter("@productid", MySqlDbType.Int32, 11), new MySqlParameter("@productcode", MySqlDbType.VarChar, 45), new MySqlParameter("@productname", MySqlDbType.VarChar, 50), new MySqlParameter("@place", MySqlDbType.VarChar, 100), new MySqlParameter("@tons", MySqlDbType.Decimal, 12), new MySqlParameter("@number", MySqlDbType.Int32, 11), new MySqlParameter("@actualnumber", MySqlDbType.Int32, 11), new MySqlParameter("@remark", MySqlDbType.VarChar, 200), new MySqlParameter("@location", MySqlDbType.VarChar, 200), new MySqlParameter("@createman", MySqlDbType.VarChar, 45), new MySqlParameter("@modifyman", MySqlDbType.VarChar, 45), new MySqlParameter("@isdelete", MySqlDbType.UInt16, 2), new MySqlParameter("@shipno", MySqlDbType.VarChar, 45), new MySqlParameter("@id", MySqlDbType.Int32, 11) }; parameters[0].Value = model.code; parameters[1].Value = model.operatecode; parameters[2].Value = model.delegateunitid; parameters[3].Value = model.delegateunitcode; parameters[4].Value = model.delegateunit; parameters[5].Value = model.deliverybills; parameters[6].Value = model.productid; parameters[7].Value = model.productcode; parameters[8].Value = model.productname; parameters[9].Value = model.place; parameters[10].Value = model.tons; parameters[11].Value = model.number; parameters[12].Value = model.actualnumber; parameters[13].Value = model.remark; parameters[14].Value = model.location; parameters[15].Value = model.createman; parameters[16].Value = model.modifyman; parameters[17].Value = model.isdelete; parameters[18].Value = model.shipno; parameters[19].Value = model.id; int rows = MySqlHelper.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(FishEntity.StorageBillsEntity model) { return(dal.Update(model)); }
/// <summary> /// 增加一条数据 /// </summary> public int Add(FishEntity.StorageBillsEntity model) { return(dal.Add(model)); }