public List <FishEntity.CallRecordsDetailEntnty> GetRecordListByWhere(string where) { StringBuilder strSql = new StringBuilder(); strSql.Append(" select * from t_callrecordsdetail where " + where); DataSet ds = MySqlHelper.Query(strSql.ToString()); List <FishEntity.CallRecordsDetailEntnty> list = new List <FishEntity.CallRecordsDetailEntnty>(); if (ds.Tables[0].Rows.Count > 0) { for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { FishEntity.CallRecordsDetailEntnty item = DataRowToModel(ds.Tables[0].Rows[i]); list.Add(item); } return(list); } else { return(null); } }
/* * /// <summary> * /// 分页获取数据列表 * /// </summary> * public DataSet GetList(int PageSize,int PageIndex,string strWhere) * { * MySqlParameter[] parameters = { * new MySqlParameter("@tblName", MySqlDbType.VarChar, 255), * new MySqlParameter("@fldName", MySqlDbType.VarChar, 255), * new MySqlParameter("@PageSize", MySqlDbType.Int32), * new MySqlParameter("@PageIndex", MySqlDbType.Int32), * new MySqlParameter("@IsReCount", MySqlDbType.Bit), * new MySqlParameter("@OrderType", MySqlDbType.Bit), * new MySqlParameter("@strWhere", MySqlDbType.VarChar,1000), * }; * parameters[0].Value = "t_callrecordsdetail"; * parameters[1].Value = "id"; * parameters[2].Value = PageSize; * parameters[3].Value = PageIndex; * parameters[4].Value = 0; * parameters[5].Value = 0; * parameters[6].Value = strWhere; * return DbHelperSQL.RunProcedure("UP_GetRecordByPage",parameters,"ds"); * }*/ #endregion BasicMethod #region ExtensionMethod public List <FishEntity.CallRecordsDetailEntnty> GetRecordListByCompanyCode(string companyCode) { StringBuilder strSql = new StringBuilder(); strSql.Append("select a.currentdate, b.* from t_callrecords a inner join t_callrecordsdetail b on a.id=b.callrecordid"); strSql.Append(" where a.customercode = @customercode order by a.currentdate desc limit 100"); MySqlParameter[] parameters = { new MySqlParameter("@customercode", MySqlDbType.VarChar, 255) }; parameters[0].Value = companyCode; DataSet ds = MySqlHelper.Query(strSql.ToString(), parameters); List <FishEntity.CallRecordsDetailEntnty> list = new List <FishEntity.CallRecordsDetailEntnty>(); if (ds.Tables[0].Rows.Count > 0) { for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { FishEntity.CallRecordsDetailEntnty item = DataRowToModel(ds.Tables[0].Rows[i]); if (ds.Tables[0].Rows[i]["currentdate"] != null) { item.currentdate = DateTime.Parse(ds.Tables[0].Rows[i]["currentdate"].ToString()); } list.Add(item); } return(list); } else { return(null); } }
/// <summary> /// 增加一条数据 /// </summary> public int Add(FishEntity.CallRecordsDetailEntnty model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into t_callrecordsdetail("); strSql.Append("callrecordid,no,nature,brand,specification,orderstate,quoteprice,weight,saleprice,paymethod,payperiod,domestic_protein,domestic_tvn,domestic_graypart,domestic_sandsalt,domestic_sour,domestic_lysine,domestic_amine,domestic_aminototal,domestic_methionine,domestic_fat)"); strSql.Append(" values ("); strSql.Append("@callrecordid,@no,@nature,@brand,@specification,@orderstate,@quoteprice,@weight,@saleprice,@paymethod,@payperiod,@domestic_protein,@domestic_tvn,@domestic_graypart,@domestic_sandsalt,@domestic_sour,@domestic_lysine,@domestic_amine,@domestic_aminototal,@domestic_methionine,@domestic_fat);"); strSql.Append("select LAST_INSERT_ID();"); MySqlParameter[] parameters = { new MySqlParameter("@callrecordid", MySqlDbType.Int32, 11), new MySqlParameter("@no", MySqlDbType.Int32, 11), new MySqlParameter("@nature", MySqlDbType.VarChar, 255), new MySqlParameter("@brand", MySqlDbType.VarChar, 255), new MySqlParameter("@specification", MySqlDbType.VarChar, 255), new MySqlParameter("@orderstate", MySqlDbType.VarChar, 255), new MySqlParameter("@quoteprice", MySqlDbType.Decimal, 10), new MySqlParameter("@weight", MySqlDbType.Decimal, 8), new MySqlParameter("@saleprice", MySqlDbType.Decimal, 10), new MySqlParameter("@paymethod", MySqlDbType.VarChar, 255), new MySqlParameter("@payperiod", MySqlDbType.VarChar, 255), new MySqlParameter("@domestic_protein", MySqlDbType.Decimal, 8), new MySqlParameter("@domestic_tvn", MySqlDbType.Decimal, 8), new MySqlParameter("@domestic_graypart", MySqlDbType.Decimal, 8), new MySqlParameter("@domestic_sandsalt", MySqlDbType.Decimal, 8), new MySqlParameter("@domestic_sour", MySqlDbType.Decimal, 8), new MySqlParameter("@domestic_lysine", MySqlDbType.Decimal, 8), new MySqlParameter("@domestic_amine", MySqlDbType.Decimal, 8), new MySqlParameter("@domestic_aminototal", MySqlDbType.Decimal, 8), new MySqlParameter("@domestic_methionine", MySqlDbType.Decimal, 8), new MySqlParameter("@domestic_fat", MySqlDbType.Decimal, 8) }; parameters[0].Value = model.callrecordid; parameters[1].Value = model.no; parameters[2].Value = model.nature; parameters[3].Value = model.brand; parameters[4].Value = model.specification; parameters[5].Value = model.orderstate; parameters[6].Value = model.quoteprice; parameters[7].Value = model.weight; parameters[8].Value = model.saleprice; parameters[9].Value = model.paymethod; parameters[10].Value = model.payperiod; parameters[11].Value = model.domestic_protein; parameters[12].Value = model.domestic_tvn; parameters[13].Value = model.domestic_graypart; parameters[14].Value = model.domestic_sandsalt; parameters[15].Value = model.domestic_sour; parameters[16].Value = model.domestic_lysine; parameters[17].Value = model.domestic_amine; parameters[18].Value = model.domestic_aminototal; parameters[19].Value = model.domestic_methionine; parameters[20].Value = model.domestic_fat; int rows = MySqlHelper.ExecuteSqlReturnId(strSql.ToString(), parameters); return(rows); }
private void InitDetail() { _detail = new List <FishEntity.CallRecordsDetailEntnty>(); for (int i = 0; i < 4; i++) { FishEntity.CallRecordsDetailEntnty item = new FishEntity.CallRecordsDetailEntnty(); item.no = i + 1; item.id = 0; item.callrecordid = 0; _detail.Add(item); } dataGridView1.AutoGenerateColumns = false; dataGridView1.DataSource = _detail; }
/// <summary> /// 得到一个对象实体 /// </summary> public FishEntity.CallRecordsDetailEntnty GetModel(int id) { StringBuilder strSql = new StringBuilder(); strSql.Append("select id,callrecordid,no,nature,brand,specification,orderstate,quoteprice,weight,saleprice,paymethod,payperiod,domestic_protein,domestic_tvn,domestic_graypart,domestic_sandsalt,domestic_sour,domestic_lysine,domestic_amine,domestic_aminototal,domestic_methionine,domestic_fat from t_callrecordsdetail "); strSql.Append(" where id=@id"); MySqlParameter[] parameters = { new MySqlParameter("@id", MySqlDbType.Int32) }; parameters[0].Value = id; FishEntity.CallRecordsDetailEntnty model = new FishEntity.CallRecordsDetailEntnty(); 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 bool Update(FishEntity.CallRecordsDetailEntnty model) { return(dal.Update(model)); }
/// <summary> /// 增加一条数据 /// </summary> public int Add(FishEntity.CallRecordsDetailEntnty model) { return(dal.Add(model)); }
/// <summary> /// 得到一个对象实体 /// </summary> public FishEntity.CallRecordsDetailEntnty DataRowToModel(DataRow row) { FishEntity.CallRecordsDetailEntnty model = new FishEntity.CallRecordsDetailEntnty(); if (row != null) { if (row["id"] != null && row["id"].ToString() != "") { model.id = int.Parse(row["id"].ToString()); } if (row["callrecordid"] != null && row["callrecordid"].ToString() != "") { model.callrecordid = int.Parse(row["callrecordid"].ToString()); } if (row["no"] != null && row["no"].ToString() != "") { model.no = int.Parse(row["no"].ToString()); } if (row["nature"] != null) { model.nature = row["nature"].ToString(); } if (row["brand"] != null) { model.brand = row["brand"].ToString(); } if (row["specification"] != null) { model.specification = row["specification"].ToString(); } if (row["orderstate"] != null) { model.orderstate = row["orderstate"].ToString(); } if (row["quoteprice"] != null && row["quoteprice"].ToString() != "") { model.quoteprice = decimal.Parse(row["quoteprice"].ToString()); } //if(row["weight"]!=null && row["weight"].ToString()!="") //{ // model.weight=decimal.Parse(row["weight"].ToString()); //} if (row["saleprice"] != null && row["saleprice"].ToString() != "") { model.saleprice = decimal.Parse(row["saleprice"].ToString()); } if (row["paymethod"] != null) { model.paymethod = row["paymethod"].ToString(); } if (row["payperiod"] != null) { model.payperiod = row["payperiod"].ToString(); } if (row["domestic_protein"] != null && row["domestic_protein"].ToString() != "") { model.domestic_protein = decimal.Parse(row["domestic_protein"].ToString()); } if (row["domestic_tvn"] != null && row["domestic_tvn"].ToString() != "") { model.domestic_tvn = decimal.Parse(row["domestic_tvn"].ToString()); } if (row["domestic_graypart"] != null && row["domestic_graypart"].ToString() != "") { model.domestic_graypart = decimal.Parse(row["domestic_graypart"].ToString()); } if (row["domestic_sandsalt"] != null && row["domestic_sandsalt"].ToString() != "") { model.domestic_sandsalt = decimal.Parse(row["domestic_sandsalt"].ToString()); } if (row["domestic_sour"] != null && row["domestic_sour"].ToString() != "") { model.domestic_sour = decimal.Parse(row["domestic_sour"].ToString()); } if (row["domestic_lysine"] != null && row["domestic_lysine"].ToString() != "") { model.domestic_lysine = decimal.Parse(row["domestic_lysine"].ToString()); } if (row["domestic_amine"] != null && row["domestic_amine"].ToString() != "") { model.domestic_amine = decimal.Parse(row["domestic_amine"].ToString()); } if (row["domestic_aminototal"] != null && row["domestic_aminototal"].ToString() != "") { model.domestic_aminototal = decimal.Parse(row["domestic_aminototal"].ToString()); } if (row["domestic_methionine"] != null && row["domestic_methionine"].ToString() != "") { model.domestic_methionine = decimal.Parse(row["domestic_methionine"].ToString()); } if (row["domestic_fat"] != null && row["domestic_fat"].ToString() != "") { model.domestic_fat = decimal.Parse(row["domestic_fat"].ToString()); } } return(model); }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(FishEntity.CallRecordsDetailEntnty model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update t_callrecordsdetail set "); strSql.Append("callrecordid=@callrecordid,"); strSql.Append("no=@no,"); strSql.Append("nature=@nature,"); strSql.Append("brand=@brand,"); strSql.Append("specification=@specification,"); strSql.Append("orderstate=@orderstate,"); strSql.Append("quoteprice=@quoteprice,"); strSql.Append("weight=@weight,"); strSql.Append("saleprice=@saleprice,"); strSql.Append("paymethod=@paymethod,"); strSql.Append("payperiod=@payperiod,"); strSql.Append("domestic_tvn=@domestic_tvn,"); strSql.Append("domestic_graypart=@domestic_graypart,"); strSql.Append("domestic_sandsalt=@domestic_sandsalt,"); strSql.Append("domestic_sour=@domestic_sour,"); strSql.Append("domestic_lysine=@domestic_lysine,"); strSql.Append("domestic_amine=@domestic_amine,"); strSql.Append("domestic_aminototal=@domestic_aminototal,"); strSql.Append("domestic_methionine=@domestic_methionine,"); strSql.Append("domestic_fat=@domestic_fat"); strSql.Append(" where id=@id"); MySqlParameter[] parameters = { new MySqlParameter("@callrecordid", MySqlDbType.Int32, 11), new MySqlParameter("@no", MySqlDbType.Int32, 11), new MySqlParameter("@nature", MySqlDbType.VarChar, 255), new MySqlParameter("@brand", MySqlDbType.VarChar, 255), new MySqlParameter("@specification", MySqlDbType.VarChar, 255), new MySqlParameter("@orderstate", MySqlDbType.VarChar, 255), new MySqlParameter("@quoteprice", MySqlDbType.Decimal, 10), new MySqlParameter("@weight", MySqlDbType.Decimal, 8), new MySqlParameter("@saleprice", MySqlDbType.Decimal, 10), new MySqlParameter("@paymethod", MySqlDbType.VarChar, 255), new MySqlParameter("@payperiod", MySqlDbType.VarChar, 255), new MySqlParameter("@domestic_tvn", MySqlDbType.Decimal, 8), new MySqlParameter("@domestic_graypart", MySqlDbType.Decimal, 8), new MySqlParameter("@domestic_sandsalt", MySqlDbType.Decimal, 8), new MySqlParameter("@domestic_sour", MySqlDbType.Decimal, 8), new MySqlParameter("@domestic_lysine", MySqlDbType.Decimal, 8), new MySqlParameter("@domestic_amine", MySqlDbType.Decimal, 8), new MySqlParameter("@domestic_aminototal", MySqlDbType.Decimal, 8), new MySqlParameter("@domestic_methionine", MySqlDbType.Decimal, 8), new MySqlParameter("@domestic_fat", MySqlDbType.Decimal, 8), new MySqlParameter("@id", MySqlDbType.Int32, 11), new MySqlParameter("@domestic_protein", MySqlDbType.Decimal, 8) }; parameters[0].Value = model.callrecordid; parameters[1].Value = model.no; parameters[2].Value = model.nature; parameters[3].Value = model.brand; parameters[4].Value = model.specification; parameters[5].Value = model.orderstate; parameters[6].Value = model.quoteprice; parameters[7].Value = model.weight; parameters[8].Value = model.saleprice; parameters[9].Value = model.paymethod; parameters[10].Value = model.payperiod; parameters[11].Value = model.domestic_tvn; parameters[12].Value = model.domestic_graypart; parameters[13].Value = model.domestic_sandsalt; parameters[14].Value = model.domestic_sour; parameters[15].Value = model.domestic_lysine; parameters[16].Value = model.domestic_amine; parameters[17].Value = model.domestic_aminototal; parameters[18].Value = model.domestic_methionine; parameters[19].Value = model.domestic_fat; parameters[20].Value = model.id; parameters[21].Value = model.domestic_protein; int rows = MySqlHelper.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
protected void AddDetail(int callrecordid, bool isAdd) { dataGridView1.EndEdit(); List <FishEntity.CallRecordsDetailEntnty> listNews = new List <FishEntity.CallRecordsDetailEntnty>(); foreach (DataGridViewRow row in dataGridView1.Rows) { if (row.IsNewRow) { continue; } FishEntity.CallRecordsDetailEntnty item = new FishEntity.CallRecordsDetailEntnty(); int id = 0; int.TryParse(row.Cells["id"].Value == null ? "0" : row.Cells["id"].Value.ToString(), out id); item.id = id; int no = 0; int.TryParse(row.Cells["no"].Value == null ? "0" : row.Cells["no"].Value.ToString(), out no); item.no = no; item.nature = row.Cells["nature"].Value == null ? string.Empty : row.Cells["nature"].Value.ToString(); item.brand = row.Cells["brand"].Value == null ? string.Empty : row.Cells["brand"].Value.ToString(); item.specification = row.Cells["specification"].Value == null ? string.Empty : row.Cells["specification"].Value.ToString(); item.orderstate = row.Cells["orderstate"].Value == null ? string.Empty : row.Cells["orderstate"].Value.ToString(); item.callrecordid = callrecordid; item.domestic_amine = GetDecimal(row.Cells["domestic_amine"].Value); item.domestic_aminototal = GetDecimal(row.Cells["domestic_aminototal"].Value); item.domestic_fat = GetDecimal(row.Cells["domestic_fat"].Value); item.domestic_graypart = GetDecimal(row.Cells["domestic_graypart"].Value); item.domestic_lysine = GetDecimal(row.Cells["domestic_lysine"].Value); item.domestic_methionine = GetDecimal(row.Cells["domestic_methionine"].Value); item.domestic_protein = GetDecimal(row.Cells["domestic_protein"].Value); item.domestic_sandsalt = GetDecimal(row.Cells["domestic_sandsalt"].Value); item.domestic_sour = GetDecimal(row.Cells["domestic_sour"].Value); item.domestic_tvn = GetDecimal(row.Cells["domestic_tvn"].Value); item.paymethod = row.Cells["paymethod"].Value == null ? string.Empty : row.Cells["paymethod"].Value.ToString(); item.payperiod = row.Cells["payperiod"].Value == null ? string.Empty : row.Cells["payperiod"].Value.ToString(); item.quoteprice = GetDecimal(row.Cells["quoteprice"].Value); item.saleprice = GetDecimal(row.Cells["saleprice"].Value); item.weight = GetDecimal(row.Cells["weight"].Value); listNews.Add(item); } if (isAdd == false) { List <FishEntity.CallRecordsDetailEntnty> listsource = _detailBll.GetModelList(" callrecordid=" + callrecordid); if (listsource != null) { foreach (FishEntity.CallRecordsDetailEntnty item in listsource) { bool isExist = listNews.Exists((i) => { return(i.id == item.id); }); if (isExist == false) { bool isDelete = _detailBll.Delete(item.id); } } } } foreach (FishEntity.CallRecordsDetailEntnty item in listNews) { if (item.id == 0) { int id = _detailBll.Add(item); if (id > 0) { item.id = id; } } else { _detailBll.Update(item); } } _detail = listNews; dataGridView1.DataSource = _detail; }