public int Update(Chain.Model.StaffClass model) { int result; if (this.Exists(model.ClassID, model.ClassName, model.ClassShopID)) { result = -1; } else { result = this.dal.Update(model); } return(result); }
public List <Chain.Model.StaffClass> DataTableToList(DataTable dt) { List <Chain.Model.StaffClass> modelList = new List <Chain.Model.StaffClass>(); int rowsCount = dt.Rows.Count; if (rowsCount > 0) { for (int i = 0; i < rowsCount; i++) { Chain.Model.StaffClass model = new Chain.Model.StaffClass(); if (dt.Rows[i]["ClassID"] != null && dt.Rows[i]["ClassID"].ToString() != "") { model.ClassID = int.Parse(dt.Rows[i]["ClassID"].ToString()); } if (dt.Rows[i]["ClassName"] != null && dt.Rows[i]["ClassName"].ToString() != "") { model.ClassName = dt.Rows[i]["ClassName"].ToString(); } if (dt.Rows[i]["ClassType"] != null && dt.Rows[i]["ClassType"].ToString() != "") { if (dt.Rows[i]["ClassType"].ToString() == "1" || dt.Rows[i]["ClassType"].ToString().ToLower() == "true") { model.ClassType = true; } else { model.ClassType = false; } } if (dt.Rows[i]["ClassPercent"] != null && dt.Rows[i]["ClassPercent"].ToString() != "") { model.ClassPercent = decimal.Parse(dt.Rows[i]["ClassPercent"].ToString()); } if (dt.Rows[i]["ClassShopID"] != null && dt.Rows[i]["ClassShopID"].ToString() != "") { model.ClassShopID = int.Parse(dt.Rows[i]["ClassShopID"].ToString()); } if (dt.Rows[i]["ClassRemark"] != null && dt.Rows[i]["ClassRemark"].ToString() != "") { model.ClassRemark = dt.Rows[i]["ClassRemark"].ToString(); } modelList.Add(model); } } return(modelList); }