public void Save(DataTable dt) { int rowsCount = dt.Rows.Count; if (rowsCount > 0) { Hownet.Model.HadnBackPrice model; for (int n = 0; n < rowsCount; n++) { string a = dt.Rows[n]["A"].ToString(); if (a != "1") { model = new Hownet.Model.HadnBackPrice(); if (dt.Rows[n]["MaterielID"].ToString() != "") { model.MaterielID = int.Parse(dt.Rows[n]["MaterielID"].ToString()); } if (dt.Rows[n]["WorkingID"].ToString() != "") { model.WorkingID = int.Parse(dt.Rows[n]["WorkingID"].ToString()); } if (dt.Rows[n]["Price"].ToString() != "") { model.Price = decimal.Parse(dt.Rows[n]["Price"].ToString()); } else { model.Price = 0; } if (dt.Rows[n]["DateTime"].ToString() != "") { model.DateTime = DateTime.Parse(dt.Rows[n]["DateTime"].ToString()); } if (dt.Rows[n]["IsUse"].ToString() != "") { model.IsUse = int.Parse(dt.Rows[n]["IsUse"].ToString()); } if (a == "3") { Add(model); } else if (a == "2") { if (dt.Rows[n]["ID"].ToString() != "") { model.ID = int.Parse(dt.Rows[n]["ID"].ToString()); Update(model); dal.UpBackPrice(model.ID); } } } } } }
/// <summary> /// 获得数据列表 /// </summary> public List <Hownet.Model.HadnBackPrice> GetModelList(string strWhere) { DataSet ds = dal.GetList(strWhere); List <Hownet.Model.HadnBackPrice> modelList = new List <Hownet.Model.HadnBackPrice>(); int rowsCount = ds.Tables[0].Rows.Count; if (rowsCount > 0) { Hownet.Model.HadnBackPrice model; for (int n = 0; n < rowsCount; n++) { model = new Hownet.Model.HadnBackPrice(); if (ds.Tables[0].Rows[n]["ID"].ToString() != "") { model.ID = int.Parse(ds.Tables[0].Rows[n]["ID"].ToString()); } if (ds.Tables[0].Rows[n]["MaterielID"].ToString() != "") { model.MaterielID = int.Parse(ds.Tables[0].Rows[n]["MaterielID"].ToString()); } if (ds.Tables[0].Rows[n]["WorkingID"].ToString() != "") { model.WorkingID = int.Parse(ds.Tables[0].Rows[n]["WorkingID"].ToString()); } if (ds.Tables[0].Rows[n]["Price"].ToString() != "") { model.Price = decimal.Parse(ds.Tables[0].Rows[n]["Price"].ToString()); } if (ds.Tables[0].Rows[n]["DateTime"].ToString() != "") { model.DateTime = DateTime.Parse(ds.Tables[0].Rows[n]["DateTime"].ToString()); } if (ds.Tables[0].Rows[n]["IsUse"].ToString() != "") { model.IsUse = int.Parse(ds.Tables[0].Rows[n]["IsUse"].ToString()); } modelList.Add(model); } } return(modelList); }
/// <summary> /// 更新一条数据 /// </summary> public void Update(Hownet.Model.HadnBackPrice model) { dal.Update(model); }
/// <summary> /// 增加一条数据 /// </summary> public int Add(Hownet.Model.HadnBackPrice model) { return(dal.Add(model)); }