protected void Button2_Click(object sender, EventArgs e)//添加维护数据 { UPHInfo uphinfo = new UPHInfo() { Process = Select1.SelectedValue, Family = Select3.SelectedValue, Attend_normal = int.Parse(TextBox1.Text), ST = TextBox6.Text, NormalUPH = int.Parse(TextBox2.Text), Cycle = TextBox3.Text, Remark = TextBox4.Text, Special = Select2.SelectedValue, //Editor = TextBox4.Text, Editor = Master.userInfo.UserId, Cdt = DateTime.Now, Udt = DateTime.Now }; IList<UPHInfo> list = uph.GetProductUPHInfoList(uphinfo); if (list != null && list.Count > 0) { Response.Write("<script>alert('数据已维护不能重复操作,请确认!')</script>"); Response.Flush(); } else { uph.AddProductUPHInfo(uphinfo); Response.Write("<script>alert('添加完成!')</script>"); Response.Flush(); } string process = Select1.SelectedValue; //GridView1 = new GridView(); this.GridView1.DataSourceID = null; DataTable dt = new DataTable(); dt = uph.GetUPHA(process); //this.GridView1.DataSource = dt; //this.GridView1.DataBind(); bindbullTable(dt, 5); TextBox1.Text = ""; TextBox2.Text = ""; TextBox3.Text = ""; TextBox4.Text = ""; TextBox6.Text = ""; }
public void AddProductUPHInfo(UPHInfo itemui) { string methodName = MethodBase.GetCurrentMethod().Name; BaseLog.LoggingBegin(logger, methodName); try { Entity.Repository.Meta.IMESSKU.UPH items = new Entity.Repository.Meta.IMESSKU.UPH { Process = itemui.Process, Attend_normal = itemui.Attend_normal, Family = itemui.Family, ST = itemui.ST, NormalUPH = itemui.NormalUPH, Cycle = itemui.Cycle, Remark = itemui.Remark, Special = itemui.Special, Editor = itemui.Editor, Cdt = itemui.Cdt, Udt = itemui.Udt }; using (UnitOfWork uow = new UnitOfWork()) { IRepository<Entity.Repository.Meta.IMESSKU.UPH> ecoModelRep = new Repository<Entity.Repository.Meta.IMESSKU.UPH>("UPHDBServer"); ecoModelRep.Insert(items); uow.Commit(); } } catch (Exception e) { BaseLog.LoggingError(logger, MethodBase.GetCurrentMethod(), e); throw; } finally { BaseLog.LoggingEnd(logger, methodName); } }
public void DelProductUPHInfo(UPHInfo itemui) { string methodName = MethodBase.GetCurrentMethod().Name; BaseLog.LoggingBegin(logger, methodName); try { Entity.Repository.Meta.IMESSKU.UPH items = new Entity.Repository.Meta.IMESSKU.UPH { Process = itemui.Process, Family = itemui.Family, Special = itemui.Remark, }; using (UnitOfWork uow = new UnitOfWork()) { IRepository<Entity.Repository.Meta.IMESSKU.UPH> ecoModelRep = new Repository<Entity.Repository.Meta.IMESSKU.UPH>("UPHDBServer"); var ret = from q in ecoModelRep.Query() where q.Process == itemui.Process && q.Family == itemui.Family && q.Special == itemui.Special select new UPHInfo { ID = q.ID, Process = q.Process, Attend_normal = q.Attend_normal, Family = q.Family, ST = q.ST.ToString(), NormalUPH = q.NormalUPH, Cycle = q.Cycle.ToString(), Remark = q.Remark, Special = q.Special, Editor = q.Editor, Cdt = q.Cdt, Udt = q.Udt }; var first = ret.First(); items.ID = first.ID; items.Process = first.Process; items.Attend_normal = first.Attend_normal; items.ST = first.ST; items.NormalUPH = first.NormalUPH; items.Cycle = first.Cycle; items.Remark = first.Remark; items.Special = first.Special; items.Editor = first.Editor; items.Cdt = first.Cdt; items.Udt = first.Udt; //IRepository<Entity.Repository.Meta.IMESSKU.UPH> ecoModelRep = new Repository<Entity.Repository.Meta.IMESSKU.UPH>("UPHDBServer"); ecoModelRep.Delete(items, true);//删掉记录 根据设置的条件 uow.Commit(); } } catch (Exception e) { BaseLog.LoggingError(logger, MethodBase.GetCurrentMethod(), e); throw; } finally { BaseLog.LoggingEnd(logger, methodName); } }
public IList<UPHInfo> GetProductUPHInfoList(UPHInfo item) { string methodName = MethodBase.GetCurrentMethod().Name; BaseLog.LoggingBegin(logger, methodName); IList<UPHInfo> ret = new List<UPHInfo>(); try { using (UnitOfWork uow = new UnitOfWork()) { IRepository<Entity.Repository.Meta.IMESSKU.UPH> ecoModelRep = new Repository<Entity.Repository.Meta.IMESSKU.UPH>("UPHDBServer");//连接字符串 查询ProductUPH 表的数据 ret = (from q in ecoModelRep.Query() where q.Process == item.Process && q.Family == item.Family && q.Special == item.Special select new UPHInfo { Process = q.Process, Attend_normal = q.Attend_normal, Family = q.Family, ST = q.ST.ToString(), NormalUPH = q.NormalUPH, Cycle = q.Cycle.ToString(), Remark = q.Remark, Special = q.Special, Editor = q.Editor, Cdt = q.Cdt, Udt = q.Udt }).ToList(); } return ret; } catch (Exception e) { BaseLog.LoggingError(logger, MethodBase.GetCurrentMethod(), e); throw; } finally { BaseLog.LoggingEnd(logger, methodName); } }
public void UpdateProductUPHInfo(UPHInfo itemui) { string methodName = MethodBase.GetCurrentMethod().Name; BaseLog.LoggingBegin(logger, methodName); try { IRepository<Entity.Repository.Meta.IMESSKU.UPH> ecoModelRep = new Repository<Entity.Repository.Meta.IMESSKU.UPH>("UPHDBServer"); var ret = from q in ecoModelRep.Query() where q.Process == itemui.Process && q.Family == itemui.Family && q.Special == itemui.Special select new UPHInfo { ID = q.ID, Process = q.Process, Attend_normal = q.Attend_normal, Family = q.Family, ST = q.ST.ToString(), NormalUPH = q.NormalUPH, Cycle = q.Cycle.ToString(), Remark = q.Remark, Special = q.Remark, Editor = q.Editor, Cdt = q.Cdt, Udt = q.Udt }; var first = ret.First(); Entity.Repository.Meta.IMESSKU.UPH items = new Entity.Repository.Meta.IMESSKU.UPH { ID = first.ID, Process = itemui.Process, Attend_normal = itemui.Attend_normal, Family = itemui.Family, ST = itemui.ST, NormalUPH = itemui.NormalUPH, Cycle = itemui.Cycle, Remark = itemui.Remark, Special = itemui.Special, Editor = itemui.Editor, Cdt = first.Cdt, Udt = itemui.Udt }; using (UnitOfWork uow = new UnitOfWork()) { ecoModelRep.Update(items); uow.Commit(); } } catch (Exception e) { BaseLog.LoggingError(logger, MethodBase.GetCurrentMethod(), e); throw; } finally { BaseLog.LoggingEnd(logger, methodName); } }
protected void Button1_Click(object sender, EventArgs e)//查询符合条件的数据 { UPHInfo uphinfo = new UPHInfo() { Process = Select1.SelectedValue, Family = Select3.SelectedValue, Special = Select2.SelectedValue, }; IList<UPHInfo> list= uph.GetProductUPHInfoList(uphinfo); if (list != null && list.Count > 0) { TextBox1.Text = list[0].Attend_normal.ToString(); TextBox2.Text = list[0].NormalUPH.ToString(); TextBox3.Text = list[0].Cycle; TextBox4.Text = list[0].Remark; TextBox6.Text = list[0].ST; } else { Response.Write("<script>alert('你查询数据为空!')</script>"); Response.Flush(); } }
private void Inutexcel2(Stream ExcelFileStream) { ToolUtility tu = new ToolUtility(); DataTable dt= tu.getExcelSheetData( ExcelFileStream,false); bindbullTable(dt,0); foreach (DataRow dr in dt.Rows) { string process= dr["Process"].ToString().Trim(); if (string.IsNullOrEmpty(process)) { break; } UPHInfo alarminfo = new UPHInfo(); alarminfo.Process = process; alarminfo.Family = dr["Family"].ToString().Trim(); alarminfo.Attend_normal = int.Parse(dr["Attend_normal"].ToString().Trim()); alarminfo.ST = dr["ST"].ToString().Trim(); alarminfo.NormalUPH = int.Parse(dr["NormalUPH"].ToString().Trim()); alarminfo.Cycle = dr["Cycle"].ToString().Trim(); alarminfo.Remark = dr["Remark"].ToString().Trim(); alarminfo.Special = dr["Special"].ToString().Trim(); // alarminfo.Editor = ((MasterPageMaintain)Master).userInfo.UserName.ToString().Trim(); alarminfo.Editor = Master.userInfo.UserId; alarminfo.Cdt = DateTime.Now; alarminfo.Udt = DateTime.Now; uph.AddProductUPHInfo(alarminfo); } }
private void InputExcel(string pPath) { string conn = "Provider = Microsoft.ACE.OLEDB.12.0 ; Data Source =" + pPath + ";Extended Properties='Excel 7.0;HDR=Yes;IMEX=1'"; OleDbConnection oleCon = new OleDbConnection(conn); oleCon.Open(); string Sql = "select DISTINCT * from [Sheet1$] WHERE Process<>''AND Family<>''AND Attend_normal<>''AND ST<>''AND Cycle<>''AND NormalUPH<>''AND Special<>''"; OleDbDataAdapter mycommand = new OleDbDataAdapter(Sql, oleCon); DataSet ds = new DataSet(); mycommand.Fill(ds, "[Sheet1$]"); oleCon.Close(); int count = ds.Tables["[Sheet1$]"].Rows.Count; UPHInfo alarminfo = new UPHInfo(); for (int i = 0; i < count; i++) { if (ds.Tables["[Sheet1$]"].Rows[i]["Process"].ToString().Trim() != "" && ds.Tables["[Sheet1$]"].Rows[i]["Family"].ToString().Trim() !="") { alarminfo.Process = ds.Tables["[Sheet1$]"].Rows[i]["Process"].ToString().Trim(); alarminfo.Family = ds.Tables["[Sheet1$]"].Rows[i]["Family"].ToString().Trim(); alarminfo.Attend_normal = int.Parse(ds.Tables["[Sheet1$]"].Rows[i]["Attend_normal"].ToString().Trim()); alarminfo.ST = ds.Tables["[Sheet1$]"].Rows[i]["ST"].ToString().Trim(); alarminfo.NormalUPH = int.Parse(ds.Tables["[Sheet1$]"].Rows[i]["NormalUPH"].ToString().Trim()); alarminfo.Cycle = ds.Tables["[Sheet1$]"].Rows[i]["Cycle"].ToString().Trim(); alarminfo.Remark = ds.Tables["[Sheet1$]"].Rows[i]["Remark"].ToString().Trim(); alarminfo.Special = ds.Tables["[Sheet1$]"].Rows[i]["Special"].ToString().Trim(); alarminfo.Editor = ((MasterPageMaintain)Master).userInfo.UserName.ToString().Trim(); alarminfo.Cdt = DateTime.Now; alarminfo.Udt = DateTime.Now; uph.AddProductUPHInfo(alarminfo); } else { break; } } Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "MyScript", "alert('导入成功!'+count)", true); }
protected void Button5_Click(object sender, EventArgs e)//修改数据 { UPHInfo uphinfo = new UPHInfo() { Process = Select1.SelectedValue, Family = Select3.SelectedValue, Special = Select2.SelectedValue, Attend_normal = int.Parse(TextBox1.Text), ST = TextBox6.Text, NormalUPH = int.Parse(TextBox2.Text), Cycle = TextBox3.Text, Remark = TextBox4.Text, //Editor = TextBox3.Text, Editor = Master.userInfo.UserId, Cdt = DateTime.Now, Udt = DateTime.Now }; IList<UPHInfo> list = uph.GetProductUPHInfoList(uphinfo); if (list != null && list.Count > 0) { string process = Select1.SelectedValue; string Family = Select3.SelectedValue; string Special = Select2.SelectedValue; string Editor = Master.userInfo.UserId; //string Editor = TextBox3.Text; uph.InsertUPH(process, Family, Special, Editor); uph.UpdateProductUPHInfo(uphinfo); Response.Write("<script>alert('修改完成!')</script>"); Response.Flush(); //GridView1 = new GridView(); this.GridView1.DataSourceID = null; DataTable dt = new DataTable(); dt = uph.GetUPHZ(process, Family, Special); // this.GridView1.DataSource = dt; // this.GridView1.DataBind(); bindbullTable(dt, 5); } else { Response.Write("<script>alert('你维护的数据不存在!')</script>"); Response.Flush(); } TextBox1.Text = ""; TextBox2.Text = ""; TextBox3.Text = ""; TextBox4.Text = ""; TextBox6.Text = ""; }