public void UpdateAlarmInfo(AlarmInfo itemui) { string methodName = MethodBase.GetCurrentMethod().Name; BaseLog.LoggingBegin(logger, methodName); try { Alarm items = new Alarm { Process = itemui.process, Class = itemui.Class, PdLine = itemui.PdLine, BeginTime = itemui.BeginTime, EndTime = itemui.EndTime, Status = itemui.Status, Remark = itemui.Remark, Editor = itemui.Editor, Cdt = itemui.Cdt, Udt = itemui.Udt }; using (UnitOfWork uow = new UnitOfWork()) { IRepository<Alarm> ecoModelRep = new Repository<Alarm>("UPHDBServer"); ecoModelRep.Update(items); uow.Commit(); } } catch (Exception e) { BaseLog.LoggingError(logger, MethodBase.GetCurrentMethod(), e); throw; } finally { BaseLog.LoggingEnd(logger, methodName); } }
protected void Button_Maintain_Click(object sender, EventArgs e) { if (Process.SelectedValue == "ALL") { Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "MyScript", "alert('请选择具体制程!')", true); } else if (Shift.SelectedValue == "ALL") { Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "MyScript", "alert('请选择具体班次!')", true); } else if (PdLine.SelectedValue == "ALL") { Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "MyScript", "alert('请选择具体线别!')", true); } //else if (get_id.Value != "" || get_id.Value != null) //{ // Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "MyScript", "alert('表中选中的数据请使用Update更新!')", true); // get_id.Value = null; //} else { AlarmInfo alarminfo = new AlarmInfo() { process = Process.SelectedValue, Class = Shift.SelectedValue, PdLine = PdLine.SelectedValue, BeginTime = BeginTime.Value, EndTime = EndTime.Value, Status = Status.SelectedValue, Remark = Request.Form["Remark"], Editor = ((MasterPageMaintain)Master).userInfo.UserId.ToString(), Cdt = DateTime.Now, Udt = DateTime.Now }; AlarmInfoLog alarminfolog = new AlarmInfoLog() { process = Process.SelectedValue, Class = Shift.SelectedValue, PdLine = PdLine.SelectedValue, BeginTime = BeginTime.Value, EndTime = EndTime.Value, Status = Status.SelectedValue, Remark = "Maintain! " + Request.Form["Remark"], Editor = ((MasterPageMaintain)Master).userInfo.UserId.ToString(), Cdt = DateTime.Now, }; if (BeginTime.Value.Trim() != "" && EndTime.Value.Trim() != "") { IAM.AddAlarmInfo(alarminfo); IAM.AddAlarmlog(alarminfolog); Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "MyScript", "alert('添加Alarm已完成!')", true); PdLine_SelectedIndexChanged1(this, null); } else { Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "MyScript", "alert('请设定需要Alarm的时间段!')", true); } } }
public void DelAlarmInfo(AlarmInfo itemui) { string methodName = MethodBase.GetCurrentMethod().Name; BaseLog.LoggingBegin(logger, methodName); try { Alarm items = new Alarm { ID=itemui.ID }; using (UnitOfWork uow = new UnitOfWork()) { IRepository<Alarm> ecoModelRep = new Repository<Alarm>("UPHDBServer"); ecoModelRep.Delete(items, true);//删掉记录 根据设置的条件 uow.Commit(); } } catch (Exception e) { BaseLog.LoggingError(logger, MethodBase.GetCurrentMethod(), e); throw; } finally { BaseLog.LoggingEnd(logger, methodName); } }
//private void InputExcel(string pPath) //{ // //FileStream file = null; // //string conn = "Provider = Microsoft.ACE.OLEDB.12.0 ; Data Source =" + pPath + ";Extended Properties='Excel 12.0;HDR=Yes;IMEX=1'"; // string connstr2003 = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + pPath + ";Extended Properties='Excel 8.0;HDR=Yes;IMEX=1;'"; // string connstr2007 = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + pPath + ";Extended Properties=\"Excel 12.0;HDR=YES\""; // OleDbConnection oleCon; // if (System.IO.Path.GetExtension(pPath) == ".xls") // { // oleCon = new OleDbConnection(connstr2003); // } // else // { // oleCon = new OleDbConnection(connstr2007); // } // oleCon.Open(); // //file = new FileStream(pPath, FileMode.Open); // string Sql = "select * from [Sheet1$] where process<>'' and Class<>'' and PdLine<>'' and BeginTime<>'' and EndTime<>'' and Status<>''"; // OleDbDataAdapter mycommand = new OleDbDataAdapter(Sql, oleCon); // DataSet ds = new DataSet(); // mycommand.Fill(ds, "[Sheet1$]"); // oleCon.Close(); // //file.Close(); // int count = ds.Tables["[Sheet1$]"].Rows.Count; // AlarmInfo alarminfo = new AlarmInfo(); // AlarmInfoLog alarminfolog = new AlarmInfoLog(); // for (int i = 0; i < count; i++) // { // if (ds.Tables["[Sheet1$]"].Rows[i]["process"].ToString().Trim() != "") // { // alarminfo.process = ds.Tables["[Sheet1$]"].Rows[i]["process"].ToString().ToUpper().Trim(); // alarminfo.Class = ds.Tables["[Sheet1$]"].Rows[i]["Class"].ToString().ToUpper().Trim(); // alarminfo.PdLine = ds.Tables["[Sheet1$]"].Rows[i]["PdLine"].ToString().ToUpper().Trim(); // alarminfo.BeginTime = Convert.ToDateTime(ds.Tables["[Sheet1$]"].Rows[i]["BeginTime"]).ToString("HH:mm").Trim(); // alarminfo.EndTime = Convert.ToDateTime(ds.Tables["[Sheet1$]"].Rows[i]["EndTime"]).ToString("HH:mm").Trim(); // alarminfo.Status = ds.Tables["[Sheet1$]"].Rows[i]["Status"].ToString().Trim(); // alarminfo.Remark = ds.Tables["[Sheet1$]"].Rows[i]["Remark"].ToString().Trim(); // alarminfo.Editor = ((MasterPageMaintain)Master).userInfo.UserName.ToString().Trim(); // alarminfo.Cdt = DateTime.Now; // alarminfo.Udt = DateTime.Now; // IAM.AddAlarmInfo(alarminfo); // //塞入Log // alarminfolog.process = ds.Tables["[Sheet1$]"].Rows[i]["process"].ToString().ToUpper().Trim(); // alarminfolog.Class = ds.Tables["[Sheet1$]"].Rows[i]["Class"].ToString().ToUpper().Trim(); // alarminfolog.PdLine = ds.Tables["[Sheet1$]"].Rows[i]["PdLine"].ToString().ToUpper().Trim(); // alarminfolog.BeginTime = Convert.ToDateTime(ds.Tables["[Sheet1$]"].Rows[i]["BeginTime"]).ToString("HH:mm").Trim(); // alarminfolog.EndTime = Convert.ToDateTime(ds.Tables["[Sheet1$]"].Rows[i]["EndTime"]).ToString("HH:mm").Trim(); // alarminfolog.Status = ds.Tables["[Sheet1$]"].Rows[i]["Status"].ToString().Trim(); // alarminfolog.Remark = "InputExcel! " + ds.Tables["[Sheet1$]"].Rows[i]["Remark"].ToString().Trim(); // alarminfolog.Editor = ((MasterPageMaintain)Master).userInfo.UserName.ToString().Trim(); // alarminfolog.Cdt = DateTime.Now; // IAM.AddAlarmlog(alarminfolog); // } // else // { // break; // } // } // Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "MyScript", "alert('导入成功!')", true); // Button_Query_Click(this, null); //} #endregion private void InputExcel(string pPath) { int NUM = 0; ToolUtility TU = new ToolUtility(); DataTable DT = TU.getExcelSheetData(pPath, false); DataTable allDT = IAM.GetAlarmALL(); foreach (DataRow DR in DT.Rows) { AlarmInfo alarminfo = new AlarmInfo() { process = DR["Process"].ToString().Trim(), Class = DR["Class"].ToString().Trim(), PdLine = DR["PdLine"].ToString().Trim(), BeginTime = DR["BeginTime"].ToString().Trim(), EndTime = DR["EndTime"].ToString().Trim(), Status = DR["Status"].ToString().Trim(), Remark = DR["Remark"].ToString().Trim(), Editor = ((MasterPageMaintain)Master).userInfo.UserId.ToString(), Cdt = DateTime.Now, Udt = DateTime.Now }; AlarmInfoLog alarminfolog = new AlarmInfoLog() { process = DR["Process"].ToString().Trim(), Class = DR["Class"].ToString().Trim(), PdLine = DR["PdLine"].ToString().Trim(), BeginTime = DR["BeginTime"].ToString().Trim(), EndTime = DR["EndTime"].ToString().Trim(), Status = DR["Status"].ToString().Trim(), Remark = "Excel Input! " + DR["Remark"].ToString().Trim(), Editor = ((MasterPageMaintain)Master).userInfo.UserId.ToString(), Cdt = DateTime.Now, }; if (alarminfo.process != "" && alarminfo.Class != "" && alarminfo.PdLine != "" && alarminfo.BeginTime != "" && alarminfo.EndTime != "") { IAM.AddAlarmInfo(alarminfo); IAM.AddAlarmlog(alarminfolog); } else { NUM += 1; continue; } foreach (DataRow allDR in allDT.Rows) { if (allDR["Class"].ToString().Trim() == DR["Class"].ToString().Trim() && allDR["PdLine"].ToString().Trim() == DR["PdLine"].ToString().Trim()) { get_id.Value = allDR["ID"].ToString().Trim(); IAM.DelAlarm(Int32.Parse(get_id.Value)); get_id.Value = null; } } } Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "MyScript", "alert('导入Excel已完成!" + NUM + "行数据不完整,未进行导入!')", true); Button_Query_Click(this, null); }