protected void btnBatchAdd_Click(object sender, EventArgs e) { if (txtKeyword.Text.Trim() == "") { MessageBox.Show(this, "请输入要批量增加的日期数字,今天后第几日"); return; } int index = int.Parse(txtKeyword.Text.Trim()); int times = DAY_TIMES; int totalnum = WORKER_NUM; int nexttotal = WORKER_NUM; Jium.BLL.serviceplan bll = new Jium.BLL.serviceplan(); DateTime pdate = DateTime.Now.AddDays(index).Date.AddHours(8); for (int i = 0; i < times; i++) { Jium.Model.serviceplan model = new Jium.Model.serviceplan(); model.id = pdate.AddMinutes(i * MINUTE_TIME_LEN).ToString("yyyyMMddHHmm"); model.plandate = pdate.AddMinutes(i * MINUTE_TIME_LEN).ToString("yyyy-MM-dd"); model.plantime = pdate.AddMinutes(i * MINUTE_TIME_LEN).ToString("HH:mm"); model.pss1 = pdate.AddMinutes(i * MINUTE_TIME_LEN + MINUTE_TIME_LEN).ToString("HH:mm"); model.totalnum = totalnum; model.leftnum = totalnum; model.nexttotal = nexttotal; model.nextleft = nexttotal; model.nextid = i == times - 1?"0": pdate.AddMinutes(i * MINUTE_TIME_LEN + MINUTE_TIME_LEN).ToString("yyyyMMddHHmm"); bll.Add(model); } txtKeyword.Text = ""; BindData(); }
/// <summary> /// 增加一条数据 /// </summary> public bool Add(Jium.Model.serviceplan model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into serviceplan("); strSql.Append("id,plandate,plantime,totalnum,leftnum,nexttotal,nextleft,nextid,pss1,pss2,pss3,pss4,pss5,psd1,psd2,psd3,psd4,psd5)"); strSql.Append(" values ("); strSql.Append("@id,@plandate,@plantime,@totalnum,@leftnum,@nexttotal,@nextleft,@nextid,@pss1,@pss2,@pss3,@pss4,@pss5,@psd1,@psd2,@psd3,@psd4,@psd5)"); MySqlParameter[] parameters = { new MySqlParameter("@id", MySqlDbType.VarChar, 20), new MySqlParameter("@plandate", MySqlDbType.VarChar, 10), new MySqlParameter("@plantime", MySqlDbType.VarChar, 10), new MySqlParameter("@totalnum", MySqlDbType.Int32, 11), new MySqlParameter("@leftnum", MySqlDbType.Int32, 11), new MySqlParameter("@nexttotal", MySqlDbType.Int32, 11), new MySqlParameter("@nextleft", MySqlDbType.Int32, 11), new MySqlParameter("@nextid", MySqlDbType.VarChar, 20), new MySqlParameter("@pss1", MySqlDbType.VarChar, 20), new MySqlParameter("@pss2", MySqlDbType.VarChar, 20), new MySqlParameter("@pss3", MySqlDbType.VarChar, 20), new MySqlParameter("@pss4", MySqlDbType.VarChar, 20), new MySqlParameter("@pss5", MySqlDbType.VarChar, 20), new MySqlParameter("@psd1", MySqlDbType.Int32, 11), new MySqlParameter("@psd2", MySqlDbType.Int32, 11), new MySqlParameter("@psd3", MySqlDbType.Int32, 11), new MySqlParameter("@psd4", MySqlDbType.Int32, 11), new MySqlParameter("@psd5", MySqlDbType.Int32, 11) }; parameters[0].Value = model.id; parameters[1].Value = model.plandate; parameters[2].Value = model.plantime; parameters[3].Value = model.totalnum; parameters[4].Value = model.leftnum; parameters[5].Value = model.nexttotal; parameters[6].Value = model.nextleft; parameters[7].Value = model.nextid; parameters[8].Value = model.pss1; parameters[9].Value = model.pss2; parameters[10].Value = model.pss3; parameters[11].Value = model.pss4; parameters[12].Value = model.pss5; parameters[13].Value = model.psd1; parameters[14].Value = model.psd2; parameters[15].Value = model.psd3; parameters[16].Value = model.psd4; parameters[17].Value = model.psd5; int rows = DbHelperMySQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
private void ShowInfo(string id) { Jium.BLL.serviceplan bll = new Jium.BLL.serviceplan(); Jium.Model.serviceplan model = bll.GetModel(id); this.lblid.Text = model.id; this.lblplandate.Text = model.plandate; this.lblplantime.Text = model.plantime; this.lbltotalnum.Text = model.totalnum.ToString(); this.lblleftnum.Text = model.leftnum.ToString(); this.lblnexttotal.Text = model.nexttotal.ToString(); this.lblnextleft.Text = model.nextleft.ToString(); this.lblnextid.Text = model.nextid; this.lblpss1.Text = model.pss1; //this.lblpss2.Text=model.pss2; //this.lblpss3.Text=model.pss3; //this.lblpss4.Text=model.pss4; //this.lblpss5.Text=model.pss5; //this.lblpsd1.Text=model.psd1.ToString(); //this.lblpsd2.Text=model.psd2.ToString(); //this.lblpsd3.Text=model.psd3.ToString(); //this.lblpsd4.Text=model.psd4.ToString(); //this.lblpsd5.Text=model.psd5.ToString(); }
/// <summary> /// 得到一个对象实体 /// </summary> public Jium.Model.serviceplan GetModel(string id) { StringBuilder strSql = new StringBuilder(); strSql.Append("select id,plandate,plantime,totalnum,leftnum,nexttotal,nextleft,nextid,pss1,pss2,pss3,pss4,pss5,psd1,psd2,psd3,psd4,psd5 from serviceplan "); strSql.Append(" where id=@id "); MySqlParameter[] parameters = { new MySqlParameter("@id", MySqlDbType.VarChar, 20) }; parameters[0].Value = id; Jium.Model.serviceplan model = new Jium.Model.serviceplan(); DataSet ds = DbHelperMySQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { return(DataRowToModel(ds.Tables[0].Rows[0])); } else { return(null); } }
public void btnSave_Click(object sender, EventArgs e) { string strErr = ""; if (this.txtplandate.Text.Trim().Length == 0) { strErr += "plandate不能为空!\\n"; } if (this.txtplantime.Text.Trim().Length == 0) { strErr += "plantime不能为空!\\n"; } if (!PageValidate.IsNumber(txttotalnum.Text)) { strErr += "totalnum格式错误!\\n"; } if (!PageValidate.IsNumber(txtleftnum.Text)) { strErr += "leftnum格式错误!\\n"; } if (!PageValidate.IsNumber(txtnexttotal.Text)) { strErr += "nexttotal格式错误!\\n"; } if (!PageValidate.IsNumber(txtnextleft.Text)) { strErr += "nextleft格式错误!\\n"; } if (this.txtnextid.Text.Trim().Length == 0) { strErr += "nextid不能为空!\\n"; } //if(this.txtpss1.Text.Trim().Length==0) //{ // strErr+="pss1不能为空!\\n"; //} //if(this.txtpss2.Text.Trim().Length==0) //{ // strErr+="pss2不能为空!\\n"; //} //if(this.txtpss3.Text.Trim().Length==0) //{ // strErr+="pss3不能为空!\\n"; //} //if(this.txtpss4.Text.Trim().Length==0) //{ // strErr+="pss4不能为空!\\n"; //} //if(this.txtpss5.Text.Trim().Length==0) //{ // strErr+="pss5不能为空!\\n"; //} //if(!PageValidate.IsNumber(txtpsd1.Text)) //{ // strErr+="psd1格式错误!\\n"; //} //if(!PageValidate.IsNumber(txtpsd2.Text)) //{ // strErr+="psd2格式错误!\\n"; //} //if(!PageValidate.IsNumber(txtpsd3.Text)) //{ // strErr+="psd3格式错误!\\n"; //} //if(!PageValidate.IsNumber(txtpsd4.Text)) //{ // strErr+="psd4格式错误!\\n"; //} //if(!PageValidate.IsNumber(txtpsd5.Text)) //{ // strErr+="psd5格式错误!\\n"; //} if (strErr != "") { MessageBox.Show(this, strErr); return; } string id = this.lblid.Text; string plandate = this.txtplandate.Text; string plantime = this.txtplantime.Text; int totalnum = int.Parse(this.txttotalnum.Text); int leftnum = int.Parse(this.txtleftnum.Text); int nexttotal = int.Parse(this.txtnexttotal.Text); int nextleft = int.Parse(this.txtnextleft.Text); string nextid = this.txtnextid.Text; string pss1 = this.txtpss1.Text; //string pss2=this.txtpss2.Text; //string pss3=this.txtpss3.Text; //string pss4=this.txtpss4.Text; //string pss5=this.txtpss5.Text; //int psd1=int.Parse(this.txtpsd1.Text); //int psd2=int.Parse(this.txtpsd2.Text); //int psd3=int.Parse(this.txtpsd3.Text); //int psd4=int.Parse(this.txtpsd4.Text); //int psd5=int.Parse(this.txtpsd5.Text); Jium.Model.serviceplan model = new Jium.Model.serviceplan(); model.id = id; model.plandate = plandate; model.plantime = plantime; model.totalnum = totalnum; model.leftnum = leftnum; model.nexttotal = nexttotal; model.nextleft = nextleft; model.nextid = nextid; model.pss1 = pss1; //model.pss2=pss2; //model.pss3=pss3; //model.pss4=pss4; //model.pss5=pss5; //model.psd1=psd1; //model.psd2=psd2; //model.psd3=psd3; //model.psd4=psd4; //model.psd5=psd5; Jium.BLL.serviceplan bll = new Jium.BLL.serviceplan(); bll.Update(model); Maticsoft.Common.MessageBox.ShowAndRedirect(this, "保存成功!", "list.aspx"); }
/// <summary> /// 得到一个对象实体 /// </summary> public Jium.Model.serviceplan DataRowToModel(DataRow row) { Jium.Model.serviceplan model = new Jium.Model.serviceplan(); if (row != null) { if (row["id"] != null) { model.id = row["id"].ToString(); } if (row["plandate"] != null) { model.plandate = row["plandate"].ToString(); } if (row["plantime"] != null) { model.plantime = row["plantime"].ToString(); } if (row["totalnum"] != null && row["totalnum"].ToString() != "") { model.totalnum = int.Parse(row["totalnum"].ToString()); } if (row["leftnum"] != null && row["leftnum"].ToString() != "") { model.leftnum = int.Parse(row["leftnum"].ToString()); } if (row["nexttotal"] != null && row["nexttotal"].ToString() != "") { model.nexttotal = int.Parse(row["nexttotal"].ToString()); } if (row["nextleft"] != null && row["nextleft"].ToString() != "") { model.nextleft = int.Parse(row["nextleft"].ToString()); } if (row["nextid"] != null) { model.nextid = row["nextid"].ToString(); } if (row["pss1"] != null) { model.pss1 = row["pss1"].ToString(); } if (row["pss2"] != null) { model.pss2 = row["pss2"].ToString(); } if (row["pss3"] != null) { model.pss3 = row["pss3"].ToString(); } if (row["pss4"] != null) { model.pss4 = row["pss4"].ToString(); } if (row["pss5"] != null) { model.pss5 = row["pss5"].ToString(); } if (row["psd1"] != null && row["psd1"].ToString() != "") { model.psd1 = int.Parse(row["psd1"].ToString()); } if (row["psd2"] != null && row["psd2"].ToString() != "") { model.psd2 = int.Parse(row["psd2"].ToString()); } if (row["psd3"] != null && row["psd3"].ToString() != "") { model.psd3 = int.Parse(row["psd3"].ToString()); } if (row["psd4"] != null && row["psd4"].ToString() != "") { model.psd4 = int.Parse(row["psd4"].ToString()); } if (row["psd5"] != null && row["psd5"].ToString() != "") { model.psd5 = int.Parse(row["psd5"].ToString()); } } return(model); }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(Jium.Model.serviceplan model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update serviceplan set "); strSql.Append("plandate=@plandate,"); strSql.Append("plantime=@plantime,"); strSql.Append("totalnum=@totalnum,"); strSql.Append("leftnum=@leftnum,"); strSql.Append("nexttotal=@nexttotal,"); strSql.Append("nextleft=@nextleft,"); strSql.Append("nextid=@nextid,"); strSql.Append("pss1=@pss1,"); strSql.Append("pss2=@pss2,"); strSql.Append("pss3=@pss3,"); strSql.Append("pss4=@pss4,"); strSql.Append("pss5=@pss5,"); strSql.Append("psd1=@psd1,"); strSql.Append("psd2=@psd2,"); strSql.Append("psd3=@psd3,"); strSql.Append("psd4=@psd4,"); strSql.Append("psd5=@psd5"); strSql.Append(" where id=@id "); MySqlParameter[] parameters = { new MySqlParameter("@plandate", MySqlDbType.VarChar, 10), new MySqlParameter("@plantime", MySqlDbType.VarChar, 10), new MySqlParameter("@totalnum", MySqlDbType.Int32, 11), new MySqlParameter("@leftnum", MySqlDbType.Int32, 11), new MySqlParameter("@nexttotal", MySqlDbType.Int32, 11), new MySqlParameter("@nextleft", MySqlDbType.Int32, 11), new MySqlParameter("@nextid", MySqlDbType.VarChar, 20), new MySqlParameter("@pss1", MySqlDbType.VarChar, 20), new MySqlParameter("@pss2", MySqlDbType.VarChar, 20), new MySqlParameter("@pss3", MySqlDbType.VarChar, 20), new MySqlParameter("@pss4", MySqlDbType.VarChar, 20), new MySqlParameter("@pss5", MySqlDbType.VarChar, 20), new MySqlParameter("@psd1", MySqlDbType.Int32, 11), new MySqlParameter("@psd2", MySqlDbType.Int32, 11), new MySqlParameter("@psd3", MySqlDbType.Int32, 11), new MySqlParameter("@psd4", MySqlDbType.Int32, 11), new MySqlParameter("@psd5", MySqlDbType.Int32, 11), new MySqlParameter("@id", MySqlDbType.VarChar, 20) }; parameters[0].Value = model.plandate; parameters[1].Value = model.plantime; parameters[2].Value = model.totalnum; parameters[3].Value = model.leftnum; parameters[4].Value = model.nexttotal; parameters[5].Value = model.nextleft; parameters[6].Value = model.nextid; parameters[7].Value = model.pss1; parameters[8].Value = model.pss2; parameters[9].Value = model.pss3; parameters[10].Value = model.pss4; parameters[11].Value = model.pss5; parameters[12].Value = model.psd1; parameters[13].Value = model.psd2; parameters[14].Value = model.psd3; parameters[15].Value = model.psd4; parameters[16].Value = model.psd5; parameters[17].Value = model.id; int rows = DbHelperMySQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }