/// <summary> /// 得到一个对象实体 /// </summary> public Maticsoft.Model.PartPutRecord DataRowToModel(DataRow row) { Maticsoft.Model.PartPutRecord model = new Maticsoft.Model.PartPutRecord(); if (row != null) { if (row["PartPutRecordID"] != null) { model.PartPutRecordID = row["PartPutRecordID"].ToString(); } if (row["PartID"] != null) { model.PartID = row["PartID"].ToString(); } if (row["PartPutNumber"] != null && row["PartPutNumber"].ToString() != "") { model.PartPutNumber = int.Parse(row["PartPutNumber"].ToString()); } if (row["PartModel"] != null) { model.PartModel = row["PartModel"].ToString(); } if (row["PartPicture"] != null) { model.PartPicture = row["PartPicture"].ToString(); } if (row["PartSource"] != null) { model.PartSource = row["PartSource"].ToString(); } if (row["PartPrice"] != null && row["PartPrice"].ToString() != "") { model.PartPrice = decimal.Parse(row["PartPrice"].ToString()); } if (row["PartPutTime"] != null && row["PartPutTime"].ToString() != "") { model.PartPutTime = DateTime.Parse(row["PartPutTime"].ToString()); } if (row["yyy1"] != null) { model.yyy1 = row["yyy1"].ToString(); } if (row["yyy2"] != null) { model.yyy2 = row["yyy2"].ToString(); } if (row["yyy3"] != null) { model.yyy3 = row["yyy3"].ToString(); } if (row["yyy4"] != null) { model.yyy4 = row["yyy4"].ToString(); } if (row["yyy15"] != null) { model.yyy15 = row["yyy15"].ToString(); } } return(model); }
protected void RadListView1_ItemCommand(object sender, Telerik.Web.UI.RadListViewCommandEventArgs e) { partsCost si = new partsCost(); if (e.CommandName == "tian")//判断是不是添加 { PartPutRecordModel = PartPutRecordBLL.GetModelyyy(e.CommandArgument.ToString()); if ((partsChoice.partsChoiceList.Where(x => x.PartPutRecordID == PartPutRecordModel.PartPutRecordID).Count() == 0)) //判断list里面有没有这条数据 { Part_Model = Part_BLL.GetModel(PartPutRecordModel.PartID); //数据库查找信息 si.PartID = PartPutRecordModel.PartID; //配件ID(子) si.Partmoney = PartPutRecordModel.PartPrice.ToString(); //价格 si.PartName = Part_Model.PartName; //名字 si.PartPicture = PartPutRecordModel.PartPicture; //图片 si.PartPrice = PartPutRecordModel.PartPrice.ToString(); //价格 si.PartUseNumber = "1"; //数量 si.PartPutNumber = PartPutRecordModel.PartPutNumber.ToString(); //库存 si.PartPutRecordID = PartPutRecordModel.PartPutRecordID; //配件入库ID partsChoice.partsChoiceList.Add(si); //加入list RadAjaxManager1.Alert("添加成功!"); // return; } else { RadAjaxManager1.Alert("已经添加过该配件!"); } } }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(Maticsoft.Model.PartPutRecord model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update PartPutRecord set "); if (model.PartID != null) { strSql.Append("PartID='" + model.PartID + "',"); } else { strSql.Append("PartID= null ,"); } if (model.PartPutNumber != null) { strSql.Append("PartPutNumber=" + model.PartPutNumber + ","); } else { strSql.Append("PartPutNumber= null ,"); } if (model.PartPutTime != null) { strSql.Append("PartPutTime='" + model.PartPutTime + "',"); } else { strSql.Append("PartPutTime= null ,"); } int n = strSql.ToString().LastIndexOf(","); strSql.Remove(n, 1); strSql.Append(" where PartPutRecordID='" + model.PartPutRecordID + "' "); int rowsAffected = DbHelperSQL.ExecuteSql(strSql.ToString()); if (rowsAffected > 0) { return(true); } else { return(false); } }
/// <summary> /// 增加一条数据 /// </summary> public bool Add(Maticsoft.Model.PartPutRecord model) { StringBuilder strSql = new StringBuilder(); StringBuilder strSql1 = new StringBuilder(); StringBuilder strSql2 = new StringBuilder(); if (model.PartPutRecordID != null) { strSql1.Append("PartPutRecordID,"); strSql2.Append("'" + model.PartPutRecordID + "',"); } if (model.PartID != null) { strSql1.Append("PartID,"); strSql2.Append("'" + model.PartID + "',"); } if (model.PartPutNumber != null) { strSql1.Append("PartPutNumber,"); strSql2.Append("" + model.PartPutNumber + ","); } if (model.PartPutTime != null) { strSql1.Append("PartPutTime,"); strSql2.Append("'" + model.PartPutTime + "',"); } strSql.Append("insert into PartPutRecord("); strSql.Append(strSql1.ToString().Remove(strSql1.Length - 1)); strSql.Append(")"); strSql.Append(" values ("); strSql.Append(strSql2.ToString().Remove(strSql2.Length - 1)); strSql.Append(")"); int rows = DbHelperSQL.ExecuteSql(strSql.ToString()); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 得到一个对象实体 /// </summary> public Maticsoft.Model.PartPutRecord GetModel(string PartPutRecordID) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 "); strSql.Append(" PartPutRecordID,PartID,PartPutNumber,PartPutTime "); strSql.Append(" from PartPutRecord "); strSql.Append(" where PartPutRecordID='" + PartPutRecordID + "' "); Maticsoft.Model.PartPutRecord model = new Maticsoft.Model.PartPutRecord(); DataSet ds = DbHelperSQL.Query(strSql.ToString()); if (ds.Tables[0].Rows.Count > 0) { return(DataRowToModel(ds.Tables[0].Rows[0])); } else { return(null); } }
/// <summary> /// 得到一个对象实体 /// </summary> public Maticsoft.Model.PartPutRecord DataRowToModel(DataRow row) { Maticsoft.Model.PartPutRecord model = new Maticsoft.Model.PartPutRecord(); if (row != null) { if (row["PartPutRecordID"] != null) { model.PartPutRecordID = row["PartPutRecordID"].ToString(); } if (row["PartID"] != null) { model.PartID = row["PartID"].ToString(); } if (row["PartPutNumber"] != null && row["PartPutNumber"].ToString() != "") { model.PartPutNumber = int.Parse(row["PartPutNumber"].ToString()); } if (row["PartPutTime"] != null && row["PartPutTime"].ToString() != "") { model.PartPutTime = DateTime.Parse(row["PartPutTime"].ToString()); } } return(model); }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(Maticsoft.Model.PartPutRecord model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update PartPutRecord set "); if (model.PartID != null) { strSql.Append("PartID='" + model.PartID + "',"); } else { strSql.Append("PartID= null ,"); } if (model.PartPutNumber != null) { strSql.Append("PartPutNumber=" + model.PartPutNumber + ","); } else { strSql.Append("PartPutNumber= null ,"); } if (model.PartModel != null) { strSql.Append("PartModel='" + model.PartModel + "',"); } else { strSql.Append("PartModel= null ,"); } if (model.PartPicture != null) { strSql.Append("PartPicture='" + model.PartPicture + "',"); } else { strSql.Append("PartPicture= null ,"); } if (model.PartSource != null) { strSql.Append("PartSource='" + model.PartSource + "',"); } else { strSql.Append("PartSource= null ,"); } if (model.PartPrice != null) { strSql.Append("PartPrice=" + model.PartPrice + ","); } else { strSql.Append("PartPrice= null ,"); } if (model.PartPutTime != null) { strSql.Append("PartPutTime='" + model.PartPutTime + "',"); } else { strSql.Append("PartPutTime= null ,"); } if (model.yyy1 != null) { strSql.Append("yyy1='" + model.yyy1 + "',"); } else { strSql.Append("yyy1= null ,"); } if (model.yyy2 != null) { strSql.Append("yyy2='" + model.yyy2 + "',"); } else { strSql.Append("yyy2= null ,"); } if (model.yyy3 != null) { strSql.Append("yyy3='" + model.yyy3 + "',"); } else { strSql.Append("yyy3= null ,"); } if (model.yyy4 != null) { strSql.Append("yyy4='" + model.yyy4 + "',"); } else { strSql.Append("yyy4= null ,"); } if (model.yyy15 != null) { strSql.Append("yyy15='" + model.yyy15 + "',"); } else { strSql.Append("yyy15= null ,"); } int n = strSql.ToString().LastIndexOf(","); strSql.Remove(n, 1); strSql.Append(" where PartPutRecordID='" + model.PartPutRecordID + "' "); int rowsAffected = DbHelperSQL.ExecuteSql(strSql.ToString()); if (rowsAffected > 0) { return(true); } else { return(false); } }
protected void RadButton2_Click(object sender, EventArgs e) { DeclarationModel = DeclarationBLL.GetModel(Request["id"].ToString()); int i = 0; if (String.IsNullOrEmpty(myEditor.InnerText)) { RadAjaxManager1.Alert("请输入故障诊断及维修方案"); return; } else { DeclarationModel.RepairPlan = myEditor.InnerText; } DeclarationModel.ResultTime = RadDatePicker1.SelectedDate; string search2 = TextBox2.Text; string xxdz2 = TextBox2.Text.Trim(); Regex pattern2 = new Regex("^[0-9]+([.]{1}[0-9]+){0,1}$"); if (TextBox2.Text == "") { RadAjaxManager1.Alert("请输入人工费用"); return; } else if ((pattern2.IsMatch(xxdz2) == false)) { RadAjaxManager1.Alert("请输入正确的人工费用");//判断输入的人工费是否正确 return; } else { DeclarationModel.PersonMoney = Convert.ToDecimal(TextBox2.Text); } string search3 = TextBox1.Text; string xxdz3 = TextBox1.Text.Trim(); Regex pattern3 = new Regex("^[0-9]+([.]{1}[0-9]+){0,1}$"); if (TextBox1.Text == "") { RadAjaxManager1.Alert("请输入维修费用"); return; } else if ((pattern3.IsMatch(xxdz3) == false)) { RadAjaxManager1.Alert("请输入正确的维修费用");//判断维修费是否正确 return; } else { DeclarationModel.RepairPrice = Convert.ToDecimal(TextBox1.Text); } DeclarationModel.PartPrice = Label5.Text; DeclarationModel.Result = "完修"; if (DeclarationModel.DeclarationState == "维修基地维修中(返修)") { DeclarationModel.DeclarationState = "维修基地已完修(返修)"; } else { DeclarationModel.DeclarationState = "维修基地已完修"; }//根据状态的不同来改变不同的维修状态 DeclarationBLL.Update(DeclarationModel); foreach (var item in partsChoice.partsChoiceList)//循环传值 { PartPutRecordModel = PartPutRecordBLL.GetModel(item.PartPutRecordID); PartPutRecordModel.PartPutNumber = PartPutRecordModel.PartPutNumber - Convert.ToInt32(item.PartUseNumber); //减掉库存数量 PartPutRecordBLL.Update(PartPutRecordModel); //update更新 PartUseRecord_Model.PartUseRecordID = DateTime.Now.ToString("yyyyMMddhhmmss") + i.ToString(); //ID PartUseRecord_Model.UserID = DeclarationModel.UserID; //用户 PartUseRecord_Model.Partmoney = Convert.ToDecimal(item.Partmoney); //金额 PartUseRecord_Model.RepairID = Request["id"].ToString(); //维修单ID PartUseRecord_Model.PartUseNumber = Convert.ToInt32(item.PartUseNumber); //数量 PartUseRecord_Model.PartID = item.PartID; //配件类别ID PartUseRecord_Model.tt2 = item.PartPutRecordID; //配件ID PartUseRecord_Model.PartUseTime = Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd")); //时间 i++; //在配件使用上加入数据 PartUseRecord_BLL.Add(PartUseRecord_Model); } partsChoice.partsChoiceList.Clear(); //清空list Response.Redirect("RepairListLS.aspx"); //跳转 }