예제 #1
0
파일: Main.cs 프로젝트: semonpic/gemdriver
 private void loadAlarm()
 {
     metroGridEquipmentAlarm.DataSource = EqpAlarm.loadDt("select * from eqp_alarm where sts<>3");
     metroGridEquipmentAlarm.Columns["ea_id"].Visible  = false;
     metroGridEquipmentAlarm.Columns["eqp_id"].Visible = false;
     metroGridEquipmentAlarm.AutoResizeColumns();
 }
예제 #2
0
        public static List <EqpAlarm> load(string query)
        {
            List <EqpAlarm> list = new List <EqpAlarm>();
            MySqlDataReader rd   = null;

            try
            {
                MySqlConnection conn = Main.getConnection();
                if (conn == null)
                {
                    return(list);
                }
                if (query == null || query.Length == 0)
                {
                    query = "select * from eqp_alarm";
                }
                Log.Info("Query: " + query);
                MySqlCommand cmd = new MySqlCommand(query, conn);

                rd = cmd.ExecuteReader();

                while (rd.Read())
                {
                    EqpAlarm obj = new EqpAlarm();
                    obj.ea_id     = Convert.ToInt32(rd["ea_id"].ToString()); // Primary
                    obj.eqp_id    = Convert.ToInt32(rd["eqp_id"].ToString());
                    obj.ea_uuid   = rd["ea_uuid"].ToString();
                    obj.ea_name   = rd["ea_name"].ToString();
                    obj.ea_alcd   = rd["ea_alcd"].ToString();
                    obj.ea_altext = rd["ea_altext"].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);
        }
예제 #3
0
        public static EqpAlarm loadUUID(string uuid)
        {
            MySqlDataReader rd = null;

            try
            {
                MySqlConnection conn = Main.getConnection();
                if (conn == null)
                {
                    return(null);
                }
                string query = "select * from eqp_alarm where ea_uuid='" + uuid + "'";
                Log.Info("Query: " + query);
                MySqlCommand cmd = new MySqlCommand(query, conn);

                rd = cmd.ExecuteReader();
                EqpAlarm obj = new EqpAlarm();

                while (rd.Read())
                {
                    obj.ea_id     = Convert.ToInt32(rd["ea_id"].ToString()); // Primary
                    obj.eqp_id    = Convert.ToInt32(rd["eqp_id"].ToString());
                    obj.ea_uuid   = rd["ea_uuid"].ToString();
                    obj.ea_name   = rd["ea_name"].ToString();
                    obj.ea_alcd   = rd["ea_alcd"].ToString();
                    obj.ea_altext = rd["ea_altext"].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);
        }
예제 #4
0
파일: Main.cs 프로젝트: semonpic/gemdriver
        private void metroGridEquipmentAlarm_Click(object sender, EventArgs e)
        {
            int Count = metroGridEquipmentAlarm.SelectedRows.Count;

            if (Count > 0)
            {
                DataGridViewRow row = metroGridEquipmentAlarm.SelectedRows[0];
                objSelectedAlarm = new EqpAlarm(row);
                //
                txt_ea_name.Text = objSelectedAlarm.ea_name;
                txt_ea_uuid.Text = objSelectedAlarm.ea_uuid;
                //
                btnUPDATEALARM.Text = "UPDATE";
                btnDeleteAlarm.Text = "DELETE";
                //
            }
        }
예제 #5
0
파일: Main.cs 프로젝트: semonpic/gemdriver
        private void btnUPDATEALARM_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrWhiteSpace(txt_ea_uuid.Text))
            {
                MessageBox.Show("Alarm ID empty", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                txt_ea_uuid.Focus();
                return;
            }
            if (string.IsNullOrWhiteSpace(txt_ea_name.Text))
            {
                MessageBox.Show("Alarm name empty", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                txt_ea_name.Focus();
                return;
            }

            if (btnUPDATEALARM.Text == "CREATE NEW")
            {
                EqpAlarm obj = new EqpAlarm();
                obj.ea_uuid = txt_ea_uuid.Text;
                obj.ea_name = txt_ea_name.Text;
                obj.sts     = 1;
                obj.eqp_id  = 1;
                obj.insert();
                //
                objSelectedAlarm = obj;
                //
                btnUPDATEALARM.Text = "UPDATE";
                btnDeleteAlarm.Text = "DELETE";
                loadAlarm();
            }
            else
            {
                if (objSelectedAlarm.ea_id > 0)
                {
                    objSelectedAlarm.ea_uuid = txt_ea_uuid.Text;
                    objSelectedAlarm.ea_name = txt_ea_name.Text;
                    objSelectedAlarm.update();
                    //
                    btnUPDATEALARM.Text = "UPDATE";
                    btnDeleteAlarm.Text = "DELETE";
                    //
                    loadAlarm();
                }
            }
        }