private void loadLinkedReport(int ee_id) { metroGridlinkedVariable.DataSource = null; metroGridLinkedReport.DataSource = null; // metroGridLinkedReport.DataSource = Eqpreport.loadDt("select r.* from eqpreport r, linkevent2report l where l.ee_id='" + ee_id + "' and l.er_id=r.er_id and r.sts<>3"); metroGridLinkedReport.Columns["er_id"].Visible = false; metroGridLinkedReport.Columns["eqp_id"].Visible = false; metroGridLinkedReport.Columns["typ"].Visible = false; metroGridLinkedReport.AutoResizeColumns(); }
public void loadCbListreport() { Dictionary <int, string> mapSecsdata = new Dictionary <int, string>(); List <Eqpreport> listEqpreport = Eqpreport.load(); foreach (Eqpreport obj in listEqpreport) { mapSecsdata.Add(obj.er_id, obj.er_uuid + "_" + obj.er_reportname); } cbListReport.DataSource = new BindingSource(mapSecsdata, null); cbListReport.DisplayMember = "Value"; cbListReport.ValueMember = "Key"; // }
private void btnNEWER_Click(object sender, EventArgs e) { if (objSelectedReport != null && objSelectedReport.er_id > 0) { DialogResult dr = MessageBox.Show("Delete event??", "Confirm delete report", MessageBoxButtons.YesNo, MessageBoxIcon.Information); if (dr == DialogResult.Yes) { // Update DB objSelectedReport.delete(); // Reload Event list loadLinkedReport(objSelectedEvent.ee_id); btnNEWER.Text = "NEW"; btnUPDATEER.Text = "INSERT"; } } else { if (btnNEWER.Text == "NEW") { btnNEWER.Text = "CREATE LINK"; btnUPDATEER.Text = "INSERT"; txt_er_uuid.Text = ""; txt_er_name.Text = ""; txt_er_sts.Checked = true; // Reload Event list } else { // create new report, and link to event objSelectedReport = new Eqpreport(); objSelectedReport.er_reportname = txt_er_name.Text; objSelectedReport.er_uuid = txt_er_uuid.Text; objSelectedReport.sts = txt_er_sts.Checked == true ? 1 : 0; // Update DB objSelectedReport.insert(); // link to event string query = "insert into linkevent2report values('" + objSelectedEvent.ee_id + "','" + objSelectedReport.er_id + "','1','1')"; objSelectedReport.query(query); // create new report, and link to event btnNEWER.Text = "NEW"; btnUPDATEER.Text = "INSERT"; // Reload report list loadLinkedReport(objSelectedEvent.ee_id); // reload combo list loadCbListreport(); // } } }
public static List <Eqpreport> load(string query) { List <Eqpreport> list = new List <Eqpreport>(); MySqlDataReader rd = null; try { MySqlConnection conn = Main.getConnection(); if (conn == null) { return(list); } if (query == null || query.Length == 0) { query = "select * from eqpreport"; } Log.Info("Query: " + query); MySqlCommand cmd = new MySqlCommand(query, conn); rd = cmd.ExecuteReader(); while (rd.Read()) { Eqpreport obj = new Eqpreport(); obj.er_id = Convert.ToInt32(rd["er_id"].ToString()); // Primary obj.eqp_id = Convert.ToInt32(rd["eqp_id"].ToString()); obj.er_uuid = rd["er_uuid"].ToString(); obj.er_reportname = rd["er_reportname"].ToString(); obj.typ = Convert.ToInt32(rd["typ"].ToString()); obj.sts = Convert.ToInt32(rd["sts"].ToString()); list.Add(obj); } rd.Close(); } catch (MySqlException e) { Log.Error("Error: " + e.Message); } finally { if (rd != null) { rd.Close(); } } return(list); }
public static Eqpreport loadUUID(string uuid) { MySqlDataReader rd = null; try { MySqlConnection conn = Main.getConnection(); if (conn == null) { return(null); } string query = "select * from eqpreport where er_uuid='" + uuid + "'"; Log.Info("Query: " + query); MySqlCommand cmd = new MySqlCommand(query, conn); rd = cmd.ExecuteReader(); Eqpreport obj = new Eqpreport(); while (rd.Read()) { obj.er_id = Convert.ToInt32(rd["er_id"].ToString()); // Primary obj.eqp_id = Convert.ToInt32(rd["eqp_id"].ToString()); obj.er_uuid = rd["er_uuid"].ToString(); obj.er_reportname = rd["er_reportname"].ToString(); obj.typ = Convert.ToInt32(rd["typ"].ToString()); obj.sts = Convert.ToInt32(rd["sts"].ToString()); break; } rd.Close(); return(obj); } catch (MySqlException e) { Log.Error("Query: " + e.Message); } finally { if (rd != null) { rd.Close(); } } return(null); }
private void btnUPDATEER_Click(object sender, EventArgs e) { if (string.IsNullOrWhiteSpace(txt_er_uuid.Text)) { MessageBox.Show("Report ID empty", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); txt_er_uuid.Focus(); return; } if (string.IsNullOrWhiteSpace(txt_er_name.Text)) { MessageBox.Show("Report name empty", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); txt_er_name.Focus(); return; } if (objSelectedReport != null && objSelectedReport.er_id > 0) { objSelectedReport.er_reportname = txt_er_name.Text; objSelectedReport.er_uuid = txt_er_uuid.Text; objSelectedReport.sts = txt_er_sts.Checked == true ? 1 : 0; // Update DB objSelectedReport.update(); // Reload Event list loadLinkedReport(objSelectedEvent.ee_id); } else { objSelectedReport = new Eqpreport(); objSelectedReport.er_reportname = txt_er_name.Text; objSelectedReport.er_uuid = txt_er_uuid.Text; objSelectedReport.sts = txt_ee_sts.Checked == true ? 1 : 0; // Update DB objSelectedReport.insert(); // Reload report list loadLinkedReport(objSelectedEvent.ee_id); // reload combo list loadCbListreport(); // } // // }
private void metroGridLinkedReport_Click(object sender, EventArgs e) { if (metroGridLinkedReport.SelectedRows.Count > 0) { DataGridViewRow row = metroGridLinkedReport.SelectedRows[0]; objSelectedReport = new Eqpreport(row); // // txt_er_uuid.Text = objSelectedReport.er_uuid; txt_er_name.Text = objSelectedReport.er_reportname; txt_er_sts.Checked = objSelectedReport.sts == 1; // loadLinkedVariable(objSelectedReport.er_id); // btnNEWER.Text = "DELETE"; btnUPDATEER.Text = "UPDATE"; } else { metroGridlinkedVariable.DataSource = null; } }
private void metroGridLinkedReport_KeyDown(object sender, KeyEventArgs e) { if (e.KeyData == Keys.Delete) { int Count = metroGridLinkedReport.SelectedRows.Count; if (Count > 0) { DataGridViewRow row = metroGridLinkedReport.SelectedRows[0]; Eqpreport obj = new Eqpreport(row); // DialogResult dr = MessageBox.Show("Remove link this report to event [" + obj.er_uuid + "]??", "Confirm", MessageBoxButtons.YesNo, MessageBoxIcon.Information); if (dr == DialogResult.Yes) { // Update DB obj.query("delete from linkevent2report where ee_id='" + objSelectedEvent.ee_id + "' and er_id='" + obj.er_id + "'"); // loadLinkedReport(objSelectedEvent.ee_id); // } } } }