/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnModify_Click(object sender, EventArgs e) { if (IsValid) { // check password // if (CheckEditPassword()) { foreach (GridViewRow row in this.GridView1.Rows) { int dataID; bool deleted; GetDataIDAndDeleted(row, out dataID, out deleted); if (deleted) { DitchDataDBI.Delete(dataID); } } this.ClientScript.RegisterStartupScript( this.GetType(), "deletsuccess", JavaScriptHelper.GetAlertScript("数据删除成功") ); } else { ClientScript.RegisterStartupScript(this.GetType(), "passworderror", GetScript("修改密码错误")); } } }
private double CountUsedAmount(int WaterUserID, DateTime bg, DateTime ed) { int[] InDevices = WaterUserInDBI.GetInDeviceIds(WaterUserID); int[] OutDevices = WaterUserOutDBI.GetOutDeviceIds(WaterUserID); double InData = 0; double OutData = 0; for (int i = 0; i < InDevices.Length; i++) { DataTable dtin = DitchDataDBI.GetData(bg, ed, InDevices[i]); if (dtin.Rows.Count != 0) { InData = InData + double.Parse(dtin.Rows[dtin.Rows.Count - 1]["UsedAmount"].ToString()) - double.Parse(dtin.Rows[0]["UsedAmount"].ToString()); } } for (int o = 0; o < OutDevices.Length; o++) { DataTable dtout = DitchDataDBI.GetData(bg, ed, OutDevices[o]); if (dtout.Rows.Count != 0) { OutData = OutData + double.Parse(dtout.Rows[dtout.Rows.Count - 1]["UsedAmount"].ToString()) - double.Parse(dtout.Rows[0]["UsedAmount"].ToString()); } } return(InData - OutData); }
private double CountChannelAmount(int ChannelID, DateTime bg, DateTime ed) { int InDevices = ChannelDBI.GetInDeviceIds(ChannelID); int OutDevices = ChannelDBI.GetOutDeviceIds(ChannelID); double InData = 0; double OutData = 0; DataTable dtin = DitchDataDBI.GetData(bg, ed, InDevices); if (dtin.Rows.Count != 0) { InData = InData + double.Parse(dtin.Rows[dtin.Rows.Count - 1]["UsedAmount"].ToString()) - double.Parse(dtin.Rows[0]["UsedAmount"].ToString()); } DataTable dtout = DitchDataDBI.GetData(bg, ed, OutDevices); if (dtout.Rows.Count != 0) { OutData = OutData + double.Parse(dtout.Rows[dtout.Rows.Count - 1]["UsedAmount"].ToString()) - double.Parse(dtout.Rows[0]["UsedAmount"].ToString()); } return(InData - OutData); }
/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void Query() { // TODO: 2011-05-27 page_load 之前不能调用 IsValid // //if (IsValid) DateTime begin = UCConditionDTTwo1.Begin; DateTime end = UCConditionDTTwo1.End; //int[] deviceIDs = UCConditionDTTwo1.GetQueryDeviceIDs(); DeviceCollection dc = UCConditionDTTwo1.Stations.GetDeviceCollection(); int[] deviceIDs = dc.GetDeviceIDs(); if (deviceIDs.Length == 0) { // TODO: 2011-05-16 not select station msg // return; } DataTable tbl = DitchDataDBI.GetData(begin, end, deviceIDs); _h.Bind(); //DataTable tbl = GetDataTable(begin, end, deviceIDs[0]); //ColumnNameTextCollection nts = GetColumnNameTextCollection(); //GridViewHelper.SetGridViewColumn(this.GridView1, nts); //this.GridView1.DataSource = tbl; //this.DataBind(); this.UCZedChart1.GraphPaneConfig = this.GetGraphPaneConfig(); this.UCZedChart1.DataSource = tbl; }
/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnModify_Click(object sender, EventArgs e) { if (IsValid) { if (CheckNewWL()) { if (CheckEditPassword()) { this.Device = this.UCChannelStationDTOne1.SelectedStation.DeviceCollection[0]; int DATE_COLUMN_INDEX = 1; int NEW_WL_COLUMN_INDEX = 4; int NEW_WL_VALUE_CONTROL_INDEX = 1; //return; foreach (GridViewRow row in this.GridView1.Rows) { int index = row.RowIndex; TextBox txtNewWL = (TextBox)row.Cells[NEW_WL_COLUMN_INDEX].Controls[NEW_WL_VALUE_CONTROL_INDEX]; string newWL = txtNewWL.Text; if (newWL.Length > 0) { int newWLValue = Convert.ToInt32(newWL); int dataID = Convert.ToInt32(this.GridView1.DataKeys[index].Value); DateTime dt = Convert.ToDateTime(row.Cells[DATE_COLUMN_INDEX].Text); float instantFlux = CalcInstantFlux(dt, newWLValue); DitchDataDBI.Update(dataID, newWLValue, 0, instantFlux); } } // re query // QueryData(); this.ClientScript.RegisterStartupScript( this.GetType(), "modifysuccess", JavaScriptHelper.GetAlertScript("数据修改成功") ); } else { // password error ClientScript.RegisterStartupScript(this.GetType(), "passworderror", GetScript("修改密码错误")); } } else { // data error ClientScript.RegisterStartupScript(this.GetType(), "dataerror", GetScript("数据错误")); } } }
/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnModify_Click(object sender, EventArgs e) { if (CheckInput()) { if (CheckEditPassword()) { this.Device = this.UCWLAdd1.SelectedStation.DeviceCollection[0]; int deviceID = this.UCWLAdd1.SelectedStation.DeviceCollection[0].DeviceID; // delete history of the day // if (this.chkDeleteHistory.Checked) { DateTime dt = this.UCWLAdd1.Begin.Date; DitchDataDBI.DeleteDay(deviceID, dt); } foreach (GridViewRow row in this.GridView1.Rows) { TextBox txtDT = row.Cells[1].Controls[1] as TextBox; TextBox txtWL = row.Cells[2].Controls[1] as TextBox; DateTime dt = Convert.ToDateTime(txtDT.Text); int wl1 = Convert.ToInt32(txtWL.Text); float flux = CalcInstantFlux(dt, wl1); DitchDataDBI.Insert(deviceID, dt, wl1, 0, flux); } // alert success msg // string addSuccessMsg = "数据添加成功"; string js = JavaScriptHelper.GetAlertScript(addSuccessMsg); this.ClientScript.RegisterStartupScript( this.GetType(), "addSuccess", js); } else { ClientScript.RegisterStartupScript( this.GetType(), "passworderror", JavaScriptHelper.GetAlertScript("修改密码错误")); } } else { string js = JavaScriptHelper.GetAlertScript("输入数据错误!"); this.ClientScript.RegisterStartupScript(this.GetType(), "key", js); } }
/// <summary> /// /// </summary> /// <param name="deviceID"></param> /// <param name="begin"></param> /// <param name="end"></param> private void QueryData(int deviceID, DateTime begin, DateTime end) { DataTable tbl = DitchDataDBI.GetWLFluxTable(begin, end, deviceID); // AddDeletedColumn // AddDeletedColumn(tbl); H.DataSource = tbl; H.Bind(); bool b = tbl.Rows.Count > 0; this.panelOpera.Visible = b; }
/// <summary> /// /// </summary> /// <returns></returns> private DataTable GetDataTable() { DateTime begin = UCConditionDTTwo1.Begin; DateTime end = UCConditionDTTwo1.End; //int[] deviceIDs = UCConditionDTTwo1.GetQueryDeviceIDs(); DeviceCollection dc = UCConditionDTTwo1.Stations.GetDeviceCollection(); int[] deviceIDs = dc.GetDeviceIDs(); if (deviceIDs.Length == 0) { // TODO: 2011-05-16 not select station msg // return(null); } //DataTable tbl = DitchDataDBI.GetData(begin, end, deviceIDs); DataTable tbl = DitchDataDBI.GetData(begin, end, deviceIDs[0]); return(tbl); }
/// <summary> /// /// </summary> /// <param name="_queryDeviceID"></param> /// <param name="_queryDateTime"></param> private void QueryData(int deviceID, DateTime begin, DateTime end) { DataTable tbl = DitchDataDBI.GetWLFluxTable(begin, end, deviceID); //this.GridView1.DataSource = tbl; //this.GridView1.DataBind(); H.DataSource = tbl; H.Bind(); if (tbl.Rows.Count > 0) { this.btnModify.Visible = true; this.lblEditPassword.Visible = true; this.txtEditPassword.Visible = true; } else { this.btnModify.Visible = false; this.lblEditPassword.Visible = false; this.txtEditPassword.Visible = false; } }
/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void Calc_Click(object sender, EventArgs e) { if (Check()) { DataTable tbl = this.GetData(); foreach (DataRow row in tbl.Rows) { int dataID = Convert.ToInt32(row["ditchdataid"]); DateTime dt = Convert.ToDateTime(row["dt"]); int wl1 = Convert.ToInt32(row["wl1"]); float flux = this.DeviceFormulaCollectionMap.FormulaCollection.CalcInstantFlux(dt, wl1, 0); DitchDataDBI.Update(dataID, wl1, 0, flux); } Query(); this.ClientScript.RegisterStartupScript( this.GetType(), "calcsuccess", JavaScriptHelper.GetAlertScript("重新计算成功") ); } }
/// <summary> /// /// </summary> /// <param name="dataID"></param> /// <param name="wl1"></param> /// <param name="instantFlux"></param> private void UpdateData(int dataID, int wl1, float instantFlux) { //TODO: // DitchDataDBI.Update(dataID, wl1, 0, instantFlux); }