private void AddRecord() { try { Decimal i = System.Convert.ToDecimal(4.1868); AddW = GiveW - BackW; MissH = Math.Round((GiveW * (GiveT - BackT) + (GiveW - BackW) * BackT) * i / 1000, 2); con = new DBcon(); SqlCommand cmd = new SqlCommand("addfactoryDatas", con.GetConnection()); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add("@p_Time", dtDate.Value.Date); cmd.Parameters.Add("@p_GiveTemp", GiveT); cmd.Parameters.Add("@p_BackTemp", BackT); cmd.Parameters.Add("@p_GiveWat", GiveW); cmd.Parameters.Add("@p_BackWat", BackW); cmd.Parameters.Add("@p_AddWat", AddW); cmd.Parameters.Add("@p_MissHeat", MissH); cmd.ExecuteNonQuery(); } catch (Exception ex) { MessageBox.Show("数据添加失败!", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); ExceptionHandler.Handle("数据添加失败!", ex); } }
public HeatParameter() { // // TODO: 在此处添加构造函数逻辑 // con = new DBcon(); }
/// <summary> /// /// </summary> private void LoadData() { try { con = new DBcon(); if (TimeBeginEnd()) { string str = "select * from v_AddPumpDatas where time between '" + m_dtBegin.Date + "' and '" + m_dtEnd.Date + "' order by team desc"; SqlDataAdapter da = new SqlDataAdapter(str, con.GetConnection()); DataSet ds = new DataSet(); da.Fill(ds, "addPumpDatas"); da.Dispose(); m_dataGrid.DataSource = ds.Tables["addPumpDatas"]; } } catch (Exception ex) { // 2007.05.30 // //MessageBox.Show("数据读取失败!","错误", //MessageBoxButtons.OK, //MessageBoxIcon.Error); ExceptionHandler.Handle("数据读取失败!", ex); } }
/// <summary> /// /// </summary> private void InitQueryBar() { try { this.panel1.Visible = false; this.splitter1.Visible = false; UnQuery(); cmbStation.Items.Add("<全部站>"); string str = "select Name from v_AddPumpDatas Group by name"; con = new DBcon(); SqlCommand cmd = new SqlCommand(str, con.GetConnection()); SqlDataReader dr = cmd.ExecuteReader(); while (dr.Read()) { cmbStation.Items.Add(dr.GetValue(0).ToString().Trim()); } dr.Close(); cmd.Dispose(); cmbStation.Text = cmbStation.Items[0].ToString(); } catch (Exception ex) { // 2007.05.30 // //MessageBox.Show("站点数据读取失败!","错误",MessageBoxButtons.OK,MessageBoxIcon.Error); ExceptionHandler.Handle("站点数据读取失败!", ex); } }
/// <summary> /// /// </summary> /// <param name="name"></param> /// <returns></returns> private int GetStationID(string name) { // int sID; // string str="select gprs_station_id,name from tbl_gprs_station"; string sql = string.Format( "select grstation_id from v_gprs_gr_xg where name = '{0}'", name ); con = new DBcon(); SqlCommand cmd = new SqlCommand(sql, con.GetConnection()); SqlDataReader dr = cmd.ExecuteReader(); int grstationId = -1; while (dr.Read()) { // if(dr.GetValue(1).ToString().Trim()==name) // { // sID=System.Convert.ToInt32(dr.GetValue(0)); // dr.Close(); // return sID; // } grstationId = int.Parse(dr[0].ToString()); } dr.Close(); return(grstationId); }
/// <summary> /// /// </summary> private void Delete() { if (NoRecordDataGrid()) { return; } int row = m_dataGrid.CurrentCell.RowNumber; int col = 1; string UserName = m_dataGrid[row, col].ToString().ToString().Trim(); if (UserName == null) { MessageBox.Show("请正确选择需要删除的数据行!", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (MessageBox.Show("确定要删除该行数据?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) != DialogResult.Yes) { return; } row = m_dataGrid.CurrentCell.RowNumber; col = 0; DBcon con = new DBcon(); int id = Convert.ToInt32(m_dataGrid[row, col].ToString()); SqlCommand sqlCmd = new SqlCommand("DELETE FROM tbl_addPumpDatas WHERE ID=" + id, con.GetConnection()); sqlCmd.ExecuteNonQuery(); sqlCmd.Dispose(); RefreshData(); }
/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void frmRMDatas_Load(object sender, System.EventArgs e) { con = new DBcon(); toolBar1.Buttons[0].Pushed = true; cmbStationLoad(); DataGridTitle(); }
/// <summary> /// /// </summary> private void UpdateRecord() { try { int grstid = GetStationID(cmbPoint.Text.Trim()); if (grstid == -1) { MessageBox.Show( "GetStationId error: " + cmbPoint.Text, "错误", MessageBoxButtons.OK, MessageBoxIcon.Error ); return; } con = new DBcon(); SqlCommand cmd = new SqlCommand("addPumpUpdate", con.GetConnection()); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add("@p_EditID", m_DataID); cmd.Parameters.Add("@p_grStationID", grstid); cmd.Parameters.Add("@p_Time", dtDate.Value.Date); cmd.Parameters.Add("@p_addPumpValue", m_Value); cmd.Parameters.Add("@p_Description", txtDescription.Text.Trim()); cmd.ExecuteNonQuery(); } catch (Exception ex) { // 2007.05.30 // //MessageBox.Show("数据编辑失败!","错误",MessageBoxButtons.OK,MessageBoxIcon.Error); ExceptionHandler.Handle("数据编辑失败!", ex); } }
/// <summary> /// /// </summary> private void EditLoad() { DateTime dt; try { con = new DBcon(); SqlCommand cmd = new SqlCommand("select * from v_AddPumpDatas where id=@m_id", con.GetConnection()); cmd.Parameters.Add("@m_id", m_DataID); SqlDataReader dr = cmd.ExecuteReader(); while (dr.Read()) { dt = System.Convert.ToDateTime(dr["time"]); dtDate.Value = dt.Date; cmbPoint.Text = dr["Name"].ToString(); txtDescription.Text = dr["Description"].ToString(); txtValue.Text = dr["addPumpValue"].ToString(); } dr.Close(); } catch (Exception ex) { // 2007.05.30 // //MessageBox.Show("数据读取失败!","错误",MessageBoxButtons.OK,MessageBoxIcon.Error); ExceptionHandler.Handle("数据读取失败!", ex); } }
private void EditLoad() { DateTime dt; try { con = new DBcon(); SqlCommand cmd = new SqlCommand("select * from tbl_factorydatas where id=@m_id", con.GetConnection()); cmd.Parameters.Add("@m_id", m_DataID); SqlDataReader dr = cmd.ExecuteReader(); while (dr.Read()) { dt = System.Convert.ToDateTime(dr["time"]); dtDate.Value = dt.Date; txtBackT.Text = dr["BackTemp"].ToString(); txtGiveT.Text = dr["GiveTemp"].ToString(); txtBackW.Text = dr["BackWat"].ToString(); txtGiveW.Text = dr["GiveWat"].ToString(); } dr.Close(); } catch (Exception ex) { // 2007.05.30 // //MessageBox.Show("数据读取失败!","错误",MessageBoxButtons.OK,MessageBoxIcon.Error); ExceptionHandler.Handle("数据读取失败!", ex); } }
/// <summary> /// /// </summary> private void cmbStationLoad() { try { cmbStation.Items.Add("<全部站>"); string str = "select name from tbl_gprs_station order by team"; con = new DBcon(); SqlCommand cmd = new SqlCommand(str, con.GetConnection()); SqlDataReader dr = cmd.ExecuteReader(); while (dr.Read()) { cmbStation.Items.Add(dr.GetValue(0).ToString().Trim()); } dr.Close(); cmd.Dispose(); cmbStation.Text = cmbStation.Items[0].ToString(); } catch (Exception ex) { // 2007.05.30 // //MessageBox.Show("站点信息加载失败!","错误",MessageBoxButtons.OK,MessageBoxIcon.Error); ExceptionHandler.Handle("站点信息加载失败!", ex); } }
/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void frmteamAddPump_Load(object sender, System.EventArgs e) { this.Text = "数据添加"; con = new DBcon(); LoadTeamName(); InitializeGridTable(); LoadDatas(); }
public RMStatistics(DateTime DT, string StationName) { // // TODO: 在此处添加构造函数逻辑 // m_DTime = DT; m_Name = StationName; con = new DBcon(); }
/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void frmFactoryDatas_Load(object sender, System.EventArgs e) { dtBegin.Value = dtEnd.Value.AddDays(-1); // this.toolBar1.Buttons[3].Pushed=true; InitQueryBar(); m_Begin = dtBegin.Value.Date; m_End = dtEnd.Value.Date; con = new DBcon(); InitializeGridTitle(); LoadDatas(m_Begin, m_End); }
/// <summary> /// /// </summary> private void InsertDatas() { try { DataTable InsertDT = (DataTable)m_dataGrid.DataSource; for (int i = 0; i < dt.Rows.Count; i++) { for (int j = 0; j < InsertDT.Rows.Count; j++) { if (InsertDT.Rows[j]["name"].ToString() == dt.Rows[i]["name"].ToString()) { if (InsertDT.Rows[j]["addPumpValue"] != System.DBNull.Value) { con = new DBcon(); SqlCommand cmd = new SqlCommand("addPumpAdd", con.GetConnection()); cmd.CommandType = CommandType.StoredProcedure; //cmd.Parameters.Add("@p_grStationID",StationID(InsertDT.Rows[j]["name"].ToString())); string stname = InsertDT.Rows[j]["name"].ToString().Trim(); int grstid = GetStationID(stname); if (grstid == -1) { MessageBox.Show( "未找到相关站名: " + stname, "错误", MessageBoxButtons.OK, MessageBoxIcon.Error ); continue; } else { cmd.Parameters.Add("@p_grStationId", grstid); } cmd.Parameters.Add("@p_Time", dtDate.Value.Date); cmd.Parameters.Add("@p_addPumpValue", System.Convert.ToDecimal(InsertDT.Rows[j]["addPumpValue"])); cmd.Parameters.Add("@p_Description", " "); cmd.ExecuteNonQuery(); } } } } } catch (Exception ex) { // 2007.05.30 // //MessageBox.Show("数据录入错误,请检查数据格式是否输入错误"); ExceptionHandler.Handle("数据录入错误,请检查数据格式是否输入错误", ex); } }
private void frmFactoryDatasItem_Load(object sender, System.EventArgs e) { if (m_bolEdit) { this.Text = "编辑数据"; EditLoad(); } else { this.Text = "添加数据"; } con = new DBcon(); }
public AddPumpAnalyse(DateTime Begin, DateTime End, string StationName, DateTime dtTitle) { // // TODO: 在此处添加构造函数逻辑 // m_Bdt = Begin.Date; m_Edt = End.Date; m_BTime = Begin; m_ETime = End; m_dtTitle = dtTitle; m_Name = StationName; con = new DBcon(); ValueFlux = new HeatParameter(); // LoadDatas(); }
private void InitializeCon(int index) { try { DBcon con = new DBcon(); string str = "select * from V_UserFunction where userID=" + index + " order by ID"; SqlDataAdapter da = new SqlDataAdapter(str, con.GetConnection()); ds = new DataSet(); da.Fill(ds, "UserFunction"); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
/// <summary> /// /// </summary> private void QueryData() { try { //ReadGridDataTitle(); con = new DBcon(); SqlDataAdapter da = new SqlDataAdapter(strQuery(), con.GetConnection()); DataSet ds = new DataSet(); da.Fill(ds, "addPumpDatas"); da.Dispose(); m_dataGrid.DataSource = ds.Tables["addPumpDatas"]; } catch (Exception ex) { MessageBox.Show(ex.ToString());//"数据查询失败!","错误",MessageBoxButtons.OK,MessageBoxIcon.Error); } }
/// <summary> /// /// </summary> /// <param name="index"></param> private void InitializeCon(int index) { try { DBcon con = new DBcon(); string str = "select * from V_UserFunction where userID=" + index + " order by ID"; SqlDataAdapter da = new SqlDataAdapter(str, con.GetConnection()); ds = new DataSet(); da.Fill(ds, "UserFunction"); } catch (Exception ex) { // 2007.05.30 // //MessageBox.Show("用户权限读取失败!","错误",MessageBoxButtons.OK,MessageBoxIcon.Error); ExceptionHandler.Handle("用户权限读取失败!", ex); } }
/// <summary> /// /// </summary> private void RefreshData() { try { con = new DBcon(); string str = "select * from v_AddPumpDatas where time between '" + m_dtBegin.Date + "' and '" + m_dtEnd.Date + "' order by team desc"; SqlDataAdapter da = new SqlDataAdapter(str, con.GetConnection()); DataSet ds = new DataSet(); da.Fill(ds, "addPumpDatasNew"); da.Dispose(); RefreshTitle(); m_dataGrid.DataSource = ds.Tables["addPumpDatasNew"]; b_New = true; } catch { MessageBox.Show("数据读取失败!", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
//#region StationID ///// <summary> ///// ///// </summary> ///// <param name="name"></param> ///// <returns></returns> //private int StationID(string name) //{ // int sID; // string str="select gprs_station_id,name from tbl_gprs_station"; // con=new DBcon(); // SqlCommand cmd=new SqlCommand(str,con.GetConnection()); // SqlDataReader dr=cmd.ExecuteReader(); // while(dr.Read()) // { // if(dr.GetValue(1).ToString().Trim()==name) // { // sID=System.Convert.ToInt32(dr.GetValue(0)); // dr.Close(); // return sID; // } // } // dr.Close(); // return 0; //} //#endregion // #region StationID /// <summary> /// /// </summary> /// <param name="name"></param> /// <returns></returns> private int GetStationID(string name) { string sql = string.Format( "select grstation_id from v_gprs_gr_xg where name = '{0}'", name ); con = new DBcon(); SqlCommand cmd = new SqlCommand(sql, con.GetConnection()); SqlDataReader dr = cmd.ExecuteReader(); int grstationId = -1; while (dr.Read()) { grstationId = int.Parse(dr[0].ToString()); } dr.Close(); return(grstationId); }
/// <summary> /// /// </summary> private void AddRecord() { try { con = new DBcon(); SqlCommand cmd = new SqlCommand("addPumpAdd", con.GetConnection()); cmd.CommandType = CommandType.StoredProcedure; int grStationId = GetStationID(cmbPoint.Text.Trim()); if (grStationId == -1) { MessageBox.Show( "error grstation id: " + grStationId + ", grstation name: " + cmbPoint.Text, "错误", MessageBoxButtons.OK, MessageBoxIcon.Error ); return; } else { cmd.Parameters.Add("@p_grStationID",//GetStationID(cmbPoint.Text.ToString().Trim())); grStationId); } cmd.Parameters.Add("@p_Time", dtDate.Value.Date); cmd.Parameters.Add("@p_addPumpValue", m_Value); cmd.Parameters.Add("@p_Description", txtDescription.Text.Trim()); cmd.ExecuteNonQuery(); } catch (Exception ex) { // 2007.05.30 // //MessageBox.Show("数据添加失败!","错误",MessageBoxButtons.OK,MessageBoxIcon.Error); ExceptionHandler.Handle("数据添加失败!", ex); } }
/// <summary> /// /// </summary> private void LoadStation() { try { // fill station name combobox // string str = "select name from tbl_gprs_station"; con = new DBcon(); SqlCommand cmd = new SqlCommand(str, con.GetConnection()); SqlDataReader dr = cmd.ExecuteReader(); while (dr.Read()) { cmbPoint.Items.Add(dr.GetValue(0).ToString().Trim()); } dr.Close(); } catch (Exception ex) { // 2007.05.30 // //MessageBox.Show("站点数据读取失败!","错误",MessageBoxButtons.OK,MessageBoxIcon.Error); ExceptionHandler.Handle("站点数据读取失败!", ex); } }