private void btnOK_Click(object sender, EventArgs e) { TNm = cmbTkN.Text; Pwd = textBox1.Text; Global.Open_Connection("General", "con"); MySqlDataAdapter adp = new MySqlDataAdapter("SELECT * FROM Sec WHERE TokenNo = '" + TNm + "'", Global.con); DataSet ds = new DataSet(); adp.Fill(ds); if (ds.Tables[0].Rows[0].ItemArray[1].ToString() == Pwd) { timer1.Stop(); //Global.ResultOK = true; frmMain frm2 = new frmMain(); frm2.FormClosed += new FormClosedEventHandler(frm2_FormClosed); frm2.Show(); this.Hide(); } else { MessageBox.Show("Oper ID No OR Password is Not Matching. Pl Try Again... "); // Global.ResultOK = true; } }
private void Fill_Combo() { try { //Sn = 0; //PrjCombo.Enabled = true; PrjCombo.Items.Clear(); PrjCombo.BackColor = Color.Green; PrjCombo.ForeColor = Color.Yellow; Global.Open_Connection("General", "con"); MySqlCommand cmd = new MySqlCommand("SELECT * FROM tblProject where ProjectFile = 'prj_" + TextBox3.Text + "'", Global.con); MySqlDataReader Rd = cmd.ExecuteReader(); while (Rd.Read()) { PrjCombo.Text = (Rd.GetValue(0).ToString()); } Global.con.Close(); if (PrjCombo.Text == "") { MessageBox.Show("Create project file first "); } } catch (Exception ex) { MessageBox.Show("Create project file first " + ex.Message); } }
private void Load_InCell() { try { int x = 0; Rw = PrjGV.CurrentRow.Index; ComboBox1.Text = PrjGV[0, Rw].Value.ToString(); ComboBox2.Text = PrjGV[1, Rw].Value.ToString(); ComboBox3.Text = PrjGV[2, Rw].Value.ToString(); ComboBox4.Text = PrjGV[3, Rw].Value.ToString(); ComboBox5.Text = PrjGV[4, Rw].Value.ToString(); ComboBox6.Text = PrjGV[5, Rw].Value.ToString(); for (x = 0; x < 10; x++) { DGPrj[1, x].Value = PrjGV[(x + 6), Rw].Value.ToString(); } Global.Open_Connection("gen_db", "con"); Adp.Update(ds.Tables[0]); } catch (Exception ex) { Global.Create_OnLog(ex.Message + " : Load In Cell....", "Alart"); //MessageBox.Show("Error Code:-11002 " + ex.Message); } }
public static void Read_LimtStandby() { try { Global.Open_Connection("lim_db", "conLim"); MySqlCommand cmd = new MySqlCommand("SELECT * FROM LIM_STANDBY", Global.conLim); MySqlDataReader Rd = cmd.ExecuteReader(); Int16 x = 0; while (Rd.Read()) { Global.Ls[x] = Rd.GetValue(3).ToString(); Global.Hs[x] = Rd.GetValue(4).ToString(); x += 1; } Rd.Close(); Global.con.Close(); Global.Create_OnLog("Limit Standard file Read Successfully .....", "Normal"); } catch (Exception ex) { Global.Create_OnLog("Limit Standard file not Read Successfully .....", "Alart"); //MessageBox.Show("Error Code:-15019", ex.Message); } }
private void SysCf_Load(object sender, EventArgs e) { int x = 0; LoadListboxes(); dgPConf.RowCount = 16; dgPConf.ColumnCount = 10; dgPConf.Font = new System.Drawing.Font("Calibri", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); Global.Open_Connection("gen_db", "con"); MySqlCommand cmd = new MySqlCommand("select * from tb_comPorts", Global.con); MySqlDataReader rd = cmd.ExecuteReader(); while (rd.Read()) { dgPConf[0, x].Value = rd.GetValue(0).ToString(); dgPConf[1, x].Value = rd.GetValue(1).ToString(); dgPConf[2, x].Value = rd.GetValue(2).ToString(); dgPConf[3, x].Value = rd.GetValue(3).ToString(); dgPConf[4, x].Value = rd.GetValue(4).ToString(); dgPConf[5, x].Value = rd.GetValue(5).ToString(); dgPConf[6, x].Value = rd.GetValue(6).ToString(); dgPConf[7, x].Value = rd.GetValue(7).ToString(); dgPConf[8, x].Value = rd.GetValue(8).ToString(); dgPConf[9, x].Value = rd.GetValue(9).ToString(); dgPConf[1, 14].Selected = true; x++; } loadInCell(); // foreach (DataGridViewRow row in dgPConf.Rows) { Boolean st = Convert.ToBoolean(row.Cells[9].Value); //string RowType = row.Cells[0].Value.ToString(); if (st == true) { chkSelect.Text = "Selected"; chkSelect.CheckState = CheckState.Checked; row.DefaultCellStyle.BackColor = Color.Gainsboro; } else if (st == false) { chkSelect.Text = "Not Selected"; chkSelect.CheckState = CheckState.Unchecked; row.DefaultCellStyle.BackColor = Color.WhiteSmoke; } } tV1.ExpandAll(); //DatagridIP.RowCount = 5; //DatagridIP[0, 0].Value = "ADAm-6018"; //DatagridIP[0, 1].Value = "ADAm-6017"; //DatagridIP[0, 2].Value = "Gantner Q-Gate"; }
//******************************************************* public void LoadDgView() { try { Global.Open_Connection("gen_db", "con"); MySqlDataAdapter adp = new MySqlDataAdapter("Select * from Tb_View Order By N", Global.con); DataSet ds = new DataSet(); adp.Fill(ds); DGView.ColumnCount = 22; if (DGView.RowCount >= 10) { DGView.RowCount = Global.Sn + 2; } else { DGView.RowCount = 12; } DGView.Font = new System.Drawing.Font("Book Antiqua", 10F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); DGView.Columns[0].Width = 50; DGView.Columns[0].Name = "Sn"; DGView.Columns[1].Width = 120; DGView.Columns[1].Name = "LogTime"; for (int i = 0; i < 20; i++) { DGView.Columns[i + 2].Width = 80; ViewNo[i] = ds.Tables[0].Rows[i].ItemArray[1].ToString(); DGView.Columns[i + 2].Name = Global.PSName[int.Parse(ViewNo[i])] + " " + Global.PUnit[int.Parse(ViewNo[i])]; } DGView.Columns[21].Width = 180; //DGView.Rows[Global.Sn].Cells[0].Value = Global.Sn; //DGView.Rows[Global.Sn].Cells[1].Value = Global.GenData[122]; for (int i = 0; i < 22; i++) { DGView.Rows[Global.Sn].Cells[i + 2].Value = Global.Data[int.Parse(ViewNo[i])]; } if (Global.Sn >= 10) { DGView.RowCount += 1; DGView.FirstDisplayedScrollingRowIndex = (Global.Sn - 5); } DGView.Rows[Global.Sn].Selected = true; } catch (Exception ex) { Global.Create_OnLog("Error in frmMain: DGView() : ", "Alart"); return;//MessageBox.Show("Error Code:- 12002", ex.Message); } }
private void button1_Click(object sender, EventArgs e) { Global.Open_Connection("gen_db", "con"); MySqlCommand cmd = new MySqlCommand("Update TbSys SET CH18 = '" + textBox36.Text + "', " + "CH19 = '" + textBox37.Text + "', " + "CH20 = '" + textBox38.Text + "', " + "CH21 = '" + textBox39.Text + "' " + " WHERE FileName = 'EngNo'", Global.con); cmd.ExecuteNonQuery(); Global.con.Close(); this.Close(); }
private void frmAbout_Load(object sender, EventArgs e) { this.Left = 350; timer1.Start(); Global.Open_Connection("General", "con"); MySqlCommand cmd = new MySqlCommand("Select Passw from Sec where TokenNo = 'LogApp'", Global.con); MySqlDataReader rd = cmd.ExecuteReader(); while (rd.Read()) { str = rd.GetValue(0).ToString(); } Global.con.Close(); }
private void Button5_Click(object sender, EventArgs e) { try { MySqlCommand cdelete = new MySqlCommand(); cdelete.CommandText = "Delete * from tblProject where ProjectFile= '" + txtFileName.Text + "'"; Global.Open_Connection("General", "con"); cdelete.Connection = Global.con; cdelete.ExecuteNonQuery(); Load_DataGrid(); } catch (Exception ex) { MessageBox.Show("Error Code:- 11006 " + ex.Message); } }
private void Button5_Click(object sender, EventArgs e) { try { MySqlCommand cdelete = new MySqlCommand(); cdelete.CommandText = "Delete from tblProject where ProjectFile= '" + ComboBox1.Text + "'"; Global.Open_Connection("gen_db", "con"); cdelete.Connection = Global.con; cdelete.ExecuteNonQuery(); Load_DataGrid(); } catch (Exception ex) { //Global.Create_OnLog(ex.Message + " : Load In Cell....", false); MessageBox.Show("Error Code:- 11006 " + ex.Message); } }
private void Load_DigInOut() { try { DGIn.RowCount = 16; Global.Open_Connection("gen_db", "con"); MySqlCommand cmd = new MySqlCommand("SELECT * FROM tbsys WHERE FileName = 'DigInPuts'", Global.con); MySqlDataReader Rd = cmd.ExecuteReader(); Int16 x = 0; while (Rd.Read()) { for (x = 0; x <= 15; x++) { DGIn[1, x].Value = Rd.GetValue(x + 1).ToString(); DGIn[1, x].Style.BackColor = Color.Green; } } Global.con.Close(); //**************************** DGOut.RowCount = 16; Global.Open_Connection("gen_db", "con"); MySqlCommand cmd1 = new MySqlCommand("SELECT * FROM tbsys WHERE FileName = 'DigOutPuts'", Global.con); MySqlDataReader Rd1 = cmd1.ExecuteReader(); x = 0; while (Rd1.Read()) { for (x = 0; x <= 15; x++) { DGOut[1, x].Value = Rd1.GetValue(x + 1).ToString(); DGOut[1, x].Style.BackColor = Color.Green; } } Global.con.Close(); } catch (Exception ex) { Global.Create_OnLog(ex.Message + " : Load DigIO....", "Alart"); //MessageBox.Show("Error Code;-5002 " + ex.Message); } }
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e) { try { /////////////////////P 27/2/2013////////////// Global.Open_Connection("gen_db", "con"); MySqlCommand cmd = new MySqlCommand("Select Passw from Sec where TokenNo= '" + comboBox1.Text + "'", Global.con); MySqlDataReader rd = cmd.ExecuteReader(); while (rd.Read()) { str = rd.GetValue(0).ToString(); } Global.con.Close(); } catch (Exception ex) { MessageBox.Show(ex.Message); Global.Create_OnLog(": comboBox1_SelectedIndex", "Alart"); } }
private void fillcombo() { try { Global.Open_Connection("gen_db", "con"); MySqlCommand cmd = new MySqlCommand("Select TokenNo from Sec", Global.con); //cmd.ExecuteNonQuery(); MySqlDataReader rd = cmd.ExecuteReader(); while (rd.Read()) { comboBox1.Items.Add(rd.GetValue(0)); } Global.con.Close(); } catch (Exception ex) { MessageBox.Show("Error Code:- 16001", ex.Message); Global.Create_OnLog("Login Failed.....", "Alart"); } }
private void Load_DigInOut() { try { // automatic DGIn.RowCount = 16; Global.Open_Connection("General", "con"); MySqlCommand cmd = new MySqlCommand("SELECT * FROM TbSys WHERE FileName = 'DigInPuts'", Global.con); MySqlDataReader Rd = cmd.ExecuteReader(); Int16 x = 0; while (Rd.Read()) { for (x = 0; x <= 15; x++) { DGIn[1, x].Value = Rd.GetValue(x + 1).ToString(); DGIn[1, x].Style.BackColor = Color.Green; } } DGOut.RowCount = 16; // //Global.Open_Connection("General", "con"); MySqlCommand cmd1 = new MySqlCommand("SELECT * FROM TbSys WHERE FileName = 'DigOutPuts'", Global.con); MySqlDataReader Rd1 = cmd1.ExecuteReader(); x = 0; while (Rd1.Read()) { for (x = 0; x <= 15; x++) { DGOut[1, x].Value = Rd1.GetValue(x + 1).ToString(); DGOut[1, x].Style.BackColor = Color.Green; } } Global.con.Close(); } catch (Exception ex) { MessageBox.Show("Error Code;-5002 " + ex.Message); } }
private void frmSimulation_Load(object sender, EventArgs e) { try { Global.Open_Connection("General", "con"); MySqlCommand cmd1 = new MySqlCommand("SELECT * FROM TbSys WHERE FileName = 'EngNo'", Global.con); MySqlDataReader Rd1 = cmd1.ExecuteReader(); while (Rd1.Read()) { textBox36.Text = Rd1.GetValue(18).ToString(); textBox37.Text = Rd1.GetValue(19).ToString(); textBox38.Text = Rd1.GetValue(20).ToString(); textBox39.Text = Rd1.GetValue(21).ToString(); } Global.con.Close(); } catch (Exception ex) { MessageBox.Show("Error - 1001", ex.Message); } }
private void frmStart_Load(object sender, EventArgs e) { flg_Resize = true; cmbTkN.Items.Clear(); Global.Open_Connection("General", "con"); MySqlCommand cmd = new MySqlCommand("SELECT * FROM Sec", Global.con); MySqlDataReader rd = cmd.ExecuteReader(); I = 0; while (rd.Read()) { if (rd.GetValue(0).ToString() != "DataSec") { I++; TkN[I] = rd.GetValue(0).ToString(); Nam[I] = rd.GetValue(1).ToString(); //cmbTkN.Items.Add(TkN[I]); // cmbTkN.SelectedIndex = 0; } } Global.con.Close(); }
private void Fill_Combo() { try { PrjCombo.Items.Clear(); PrjCombo.BackColor = Color.Green; PrjCombo.ForeColor = Color.Yellow; Global.Open_Connection("gen_db", "con"); MySqlCommand cmd = new MySqlCommand("SELECT * FROM tblProject", Global.con); MySqlDataReader Rd = cmd.ExecuteReader(); while (Rd.Read()) { PrjCombo.Items.Add(Rd.GetValue(0).ToString()); } Rd.Close(); Global.con.Close(); } catch (Exception ex) { MessageBox.Show("Error in EngDialog: Fill_Combo: " + ex.Message); } }
private void button1_Click(object sender, EventArgs e) { try { Global.Open_Connection("gen_db", "con"); MySqlCommand cmd = new MySqlCommand("Select Passw from Sec where TokenNo= '" + comboBox1.Text + "'", Global.con); MySqlDataReader rd = cmd.ExecuteReader(); while (rd.Read()) { str = rd.GetValue(0).ToString(); } Global.con.Close(); if ((str == textBox1.Text.Trim()) && (comboBox1.Text.Trim() == "Supervisor")) { Global.flg_Log_supervisor = true; this.Close(); } else if ((str == textBox1.Text.Trim()) && (comboBox1.Text.Trim() == "Service")) { Global.flg_Log_service = true; this.Close(); } else { MessageBox.Show("Password is wrong "); textBox1.Text = ""; comboBox1.Text = ""; comboBox1.Focus(); Global.flg_Log_supervisor = false; Global.flg_Log_service = false; } } catch (Exception ex) { //MessageBox.Show("Error Code:- 16002", ex.Message); Global.Create_OnLog("Check Password ", "Alart"); // button1_Click"); } }
private void Load_InCell() { try { int x = 0; Rw = PrjGV.CurrentRow.Index; txtFileName.Text = PrjGV[0, Rw].Value.ToString(); ComboBox2.Text = PrjGV[1, Rw].Value.ToString(); ComboBox3.Text = PrjGV[2, Rw].Value.ToString(); ComboBox4.Text = PrjGV[3, Rw].Value.ToString(); ComboBox5.Text = PrjGV[4, Rw].Value.ToString(); ComboBox6.Text = PrjGV[5, Rw].Value.ToString(); for (x = 0; x < 10; x++) { DGPrj[1, x].Value = PrjGV[(x + 6), Rw].Value.ToString(); } Global.Open_Connection("General", "con"); Adp.Update(ds.Tables[0]); } catch (Exception ex) { MessageBox.Show("Error Code:-11002 " + ex.Message); } }
private void btnASave_Click(object sender, EventArgs e) { try { Global.JobOrdNo = "***"; Process[] prs = Process.GetProcesses(); foreach (Process pr in prs) { //if (pr.ProcessName == "ModbusPollCS") pr.Kill(); if (pr.ProcessName == "Editors") { pr.Kill(); } if (pr.ProcessName == "Dataappliacation") { pr.Kill(); } } if (TextBox1.Text == String.Empty) // "") { MessageBox.Show("Please Type Engine No. ...... "); TextBox1.Focus(); } else if (PrjCombo.Text == String.Empty) { MessageBox.Show("Please Select Project. ...... "); PrjCombo.Focus(); } else if ((textBox7.Text == String.Empty) || (textBox8.Text == String.Empty) || (textBox13.Text == String.Empty)) { Erp1.SetError(groupBox2, "Some Input Value Is missing." + "\n\n" + " 1. Engine Idle RPM " + "\n" + " 2. Engine FlyUp RPM " + "\n" + " 3. Engine Max Power @ RPM " + "\n" + " 4. Engine Max Torque@ RPM "); MessageBox.Show("Some Input Value Is missing." + "\n\n" + " 1. Engine Idle RPM " + "\n" + " 2. Engine FlyUp RPM " + "\n" + " 3. Engine Max Power @ RPM " + "\n" + " 4. Engine Max Torque@ RPM "); groupBox2.Focus(); } else { Global.EngNo = TextBox1.Text; Global.EngineNo = TextBox1.Text; Global.FipNo = TextBox2.Text; Global.EngMd = TextBox3.Text; Global.OperatorNm = TextBox4.Text; Global.EnginerNm = TextBox5.Text; Global.TestRef = TextBox6.Text; Global.PrjNm = PrjCombo.Text; Global.T_Date = TextBox9.Text; Global.Shift = TextBox10.Text; Global.HzLog = HzCombo.Text; if (checkBox1.CheckState == CheckState.Checked) { Global.flg_smk = true; } else { Global.flg_smk = false; } if (checkBox2.CheckState == CheckState.Checked) { Global.flg_Radiator = true; } else { Global.flg_Radiator = false; } if (checkBox3.CheckState == CheckState.Checked) { Global.flg_Fan = true; } else { Global.flg_Fan = false; } if (checkBox4.CheckState == CheckState.Checked) { Global.flg_AirCln = true; } else { Global.flg_AirCln = false; } if (checkBox5.CheckState == CheckState.Checked) { Global.flg_Silincer = true; } else { Global.flg_Silincer = false; } if (rd_New.Checked == true) { Global.flg_NewFile = true; } else { Global.flg_NewFile = false; } if (rd_Last.Checked == true) { Global.flg_OldFile = true; } else { Global.flg_OldFile = false; } if (rd_smooth.Checked == true) { Global.flg_Smt_Changeover = true; } else { Global.flg_Smt_Changeover = false; } if (rd_standard.Checked == true) { Global.flg_Std_Changeover = true; } else { Global.flg_Std_Changeover = false; } String X = textBox7.Text; Global.S_Rpm = int.Parse(X); Global.I_Rpm = (int.Parse(X) + int.Parse(X) / 10); String Y = textBox8.Text; Global.F_Rpm = (int.Parse(Y) + int.Parse(Y) / 10); String Z = textBox13.Text; Global.Max_Trq = (Double.Parse(Z) + (Double.Parse(Z) / 10)); Global.Open_Connection("gen_db", "con"); MySqlCommand cmd = new MySqlCommand("UPDATE TbSys SET " + " CH1 = '" + Global.EngNo + "'," + " CH2 = '" + Global.FipNo + "'," + " CH3 = '" + Global.EngMd + "'," + " CH4 = '" + Global.OperatorNm + "'," + " CH5 = '" + Global.TKnNo + "'," + " CH6 = '" + Global.TestRef + "'," + " CH7 = '" + Global.PrjNm + "'," + " CH8 = '" + Global.flg_smk + "'," + " CH9 = '" + Global.flg_Radiator + "'," + " CH10 = '" + Global.flg_Fan + "'," + " CH11 = '" + Global.flg_AirCln + "'," + " CH12 = '" + Global.flg_Silincer + "'," + " CH13 = '" + Global.flg_NewFile + "'," + " CH14 = '" + Global.flg_OldFile + "'," + " CH15 = '" + Global.flg_Smt_Changeover + "'," + " CH16 = '" + Global.flg_Std_Changeover + "'," + " CH17 = '" + X + "'," + " CH18 = '" + Y + "'," + " CH19 = '" + Z + "'," + " CH20 = '" + Global.HzLog + "'" + " WHERE FileName = 'EngNo'", Global.con); cmd.ExecuteNonQuery(); Global.con.Close(); Global.Rd_System(); Global.PrjNm = PrjCombo.Text; Check_File_Validation(); Global.flg_Auto = true; Global.flg_Manual = false; Global.Read_Eng(); clsLimit.Read_Limfl(); Global.Flg_Ready = true; Global.main.BtnSA.Enabled = false; Global.main.Btn21.Enabled = true; Global.flg_Semi_Auto = false; switch (HzCombo.Text) { case "100 Hz": Global.Dly_cnt = 10000; break; case "080 Hz": Global.Dly_cnt = 12500; break; case "060 Hz": Global.Dly_cnt = 16667; break; case "050 Hz": Global.Dly_cnt = 20000; break; case "040 Hz": Global.Dly_cnt = 25000; break; case "020 Hz": Global.Dly_cnt = 50000; break; case "010 Hz": Global.Dly_cnt = 100000; break; case "001 Hz": Global.Dly_cnt = 1000000; break; default: Global.Dly_cnt = 1000000; break; } //Global.flg_RunStart = true; this.Close(); } } catch (Exception ex) { Global.Create_OnLog(ex.Message + " : Engine Dialog Save Auto File....", "Alart"); } }
private void btnSavePort_Click(object sender, EventArgs e) { try { int x = dgPConf.CurrentRow.Index; dgPConf[1, x].Value = cmbDeviceName.Text; dgPConf[2, x].Value = cmbPort.Text; dgPConf[3, x].Value = cmbBaudRate.Text; dgPConf[4, x].Value = cmbParity.Text; dgPConf[5, x].Value = cmbStopBit.Text; dgPConf[6, x].Value = txtInstID.Text; dgPConf[7, x].Value = txtStartAdd.Text; dgPConf[8, x].Value = txtNReads.Text; if (chkSelect.Text == "Selected") { dgPConf[9, x].Value = "True"; } else if (chkSelect.Text == "Not Selected") { dgPConf[9, x].Value = "False"; } //string S = dgPConf[9, x].Value; Boolean st = Convert.ToBoolean(dgPConf[9, Rw].Value); foreach (DataGridViewRow row in dgPConf.Rows) { if (st == true) { chkSelect.Text = "Selected"; chkSelect.CheckState = CheckState.Checked; dgPConf.Rows[Rw].DefaultCellStyle.BackColor = Color.Gainsboro; } else if (st == false) { chkSelect.Text = "Not Selected"; chkSelect.CheckState = CheckState.Unchecked; dgPConf.Rows[Rw].DefaultCellStyle.BackColor = Color.WhiteSmoke; } } //----------------Save int y = x + 1; Global.Open_Connection("gen_db", "con"); MySqlCommand cmd = new MySqlCommand(); cmd.CommandText = "UPDATE tb_comports SET " + " ComPorts = '" + cmbPort.Text + "'," + " BaudRates = '" + cmbBaudRate.Text + "'," + " Parity = '" + cmbParity.Text + "'," + " StopBit = '" + cmbStopBit.Text + "'," + " InstId = '" + txtInstID.Text + "'," + " StartAdd = '" + txtStartAdd.Text + "'," + " NReads = '" + txtNReads.Text + "'," + " State = '" + st + "'" + " WHERE DeviceNames = '" + cmbDeviceName.Text + "'"; cmd.Connection = Global.con; cmd.ExecuteNonQuery(); if (Rw == 1) // Save ADAM 1 CONFIGURATION { Global.Open_Connection("gen_db", "con"); MySqlCommand cmd1 = new MySqlCommand(); cmd1.CommandText = "UPDATE tbsys SET " + " CH1 = '" + txtM1.Text + "'," + " CH2 = '" + ADAMType1.Text + "'," + " CH3 = '" + ADAMRange1.Text + "'," + " CH4 = '" + txtM2.Text + "'," + " CH5 = '" + ADAMType2.Text + "'," + " CH6 = '" + ADAMRange2.Text + "'," + " CH7 = '" + txtM3.Text + "'," + " CH8 = '" + ADAMType3.Text + "'," + " CH9 = '" + ADAMRange3.Text + "'," + " CH10 = '" + txtM4.Text + "'," + " CH11 = '" + ADAMType4.Text + "'," + " CH12 = '" + ADAMRange4.Text + "'," + " CH13 = '" + txtM5.Text + "'," + " CH14 = '" + ADAMType5.Text + "'," + " CH15 = '" + ADAMRange5.Text + "'" + " WHERE FileName = 'ADAMGroup01'"; cmd1.Connection = Global.con; cmd1.ExecuteNonQuery(); } else if (Rw == 2) // Save ADAM 2 CONFIGURATION { Global.Open_Connection("gen_db", "con"); MySqlCommand cmd2 = new MySqlCommand(); cmd2.CommandText = "UPDATE tbsys SET " + " CH1 = '" + txtM1.Text + "'," + " CH2 = '" + ADAMType1.Text + "'," + " CH3 = '" + ADAMRange1.Text + "'," + " CH4 = '" + txtM2.Text + "'," + " CH5 = '" + ADAMType2.Text + "'," + " CH6 = '" + ADAMRange2.Text + "'," + " CH7 = '" + txtM3.Text + "'," + " CH8 = '" + ADAMType3.Text + "'," + " CH9 = '" + ADAMRange3.Text + "'," + " CH10 = '" + txtM4.Text + "'," + " CH11 = '" + ADAMType4.Text + "'," + " CH12 = '" + ADAMRange4.Text + "'," + " CH13 = '" + txtM5.Text + "'," + " CH14 = '" + ADAMType5.Text + "'," + " CH15 = '" + ADAMRange5.Text + "'" + " WHERE FileName = 'ADAMGroup02'"; cmd2.Connection = Global.con; cmd2.ExecuteNonQuery(); } Global.Create_OnLog("System Port Configuration File Is Saved Properly ", "Normal"); loadInCell(); } catch (Exception ex) { Global.Create_OnLog("System Port Configuration File Is not Saved Properly ", "Alart"); MessageBox.Show(ex.Message); } }
private void frmProject_Load(object sender, EventArgs e) { try { ComboBox1.Items.Clear(); ComboBox2.Items.Clear(); ComboBox3.Items.Clear(); ComboBox4.Items.Clear(); DGPrj.RowCount = 10; DGPrj.RowTemplate.Height = 30; foreach (DataGridViewColumn colm in DGPrj.Columns) { colm.SortMode = DataGridViewColumnSortMode.NotSortable; } DGPrj[0, 0].Value = "Engine Rated Power (kW):"; DGPrj[0, 1].Value = "@ Engine rpm :"; DGPrj[0, 2].Value = "Engine Rated Torque (Nm):"; DGPrj[0, 3].Value = "@ Engine rpm :"; DGPrj[0, 4].Value = "Engine Flyup RPM:"; DGPrj[0, 5].Value = "Engine Idle RPM:"; DGPrj[0, 6].Value = "Engine Start RPM:"; DGPrj[0, 7].Value = "Engine Start plus Duration(s)"; DGPrj[0, 8].Value = "Engine Cummulative (hr.mm):"; DGPrj[0, 9].Value = "Log PM' Data After Eng.OFF(secs)"; DGPrj.Columns[1].DefaultCellStyle.ForeColor = Color.Red; ComboBox3.Items.Clear(); ComboBox3.Refresh(); Global.Open_Connection("seq_db", "conSeq"); MySqlCommand cmd = new MySqlCommand("SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES where TABLE_SCHEMA='seq_db'", Global.conSeq); using (MySqlDataReader reader = cmd.ExecuteReader()) { ComboBox3.Items.Clear(); while (reader.Read()) { ComboBox3.Items.Add((string)reader["TABLE_NAME"]); } reader.Dispose(); } cmd.Dispose(); Global.conSeq.Close(); ComboBox3.SelectedIndex = 0; //---------------------------------- ComboBox4.Items.Clear(); ComboBox4.Refresh(); Global.Open_Connection("lim_db", "conLim"); MySqlCommand cmd1 = new MySqlCommand("SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES where TABLE_SCHEMA = 'lim_db'", Global.conLim); using (MySqlDataReader reader = cmd1.ExecuteReader()) { ComboBox4.Items.Clear(); while (reader.Read()) { ComboBox4.Items.Add((string)reader["TABLE_NAME"]); } reader.Close(); } cmd1.Dispose(); Global.conLim.Close(); ComboBox4.SelectedIndex = 0; Global.Open_Connection("gen_db", "con"); Adp = new MySqlDataAdapter("SELECT * FROM tblEngine", Global.con); ds = new DataSet(); Adp.Fill(ds); int x = 0; ComboBox2.Items.Clear(); for (x = 0; x <= (ds.Tables[0].Rows.Count - 1); x++) { ComboBox2.Items.Add(ds.Tables[0].Rows[x].ItemArray[0]); } ds.Dispose(); Adp.Dispose(); Global.Open_Connection("gen_db", "con"); Adp = new MySqlDataAdapter("Select * from tblProject", Global.con); ds = new DataSet(); Adp.Fill(ds); PrjGV.DataSource = ds.Tables[0]; PrjGV.Columns[0].Width = 100; PrjGV.Columns[1].Width = 100; PrjGV.Columns[2].Width = 100; PrjGV.Columns[3].Width = 100; PrjGV.Columns[4].Width = 100; PrjGV.Columns[5].Width = 100; PrjGV.Columns[6].Width = 60; PrjGV.Columns[7].Width = 60; PrjGV.Columns[8].Width = 60; PrjGV.Columns[9].Width = 60; PrjGV.Columns[10].Width = 60; PrjGV.Columns[11].Width = 60; PrjGV.Columns[12].Width = 60; PrjGV.Columns[13].Width = 60; PrjGV.Columns[14].Width = 60; PrjGV.Columns[15].Width = 60; foreach (DataGridViewColumn colm in PrjGV.Columns) { colm.SortMode = DataGridViewColumnSortMode.NotSortable; } Adp.Update(ds.Tables[0]); Load_InCell(); } catch (Exception ex) { Global.Create_OnLog("ex.Message .........", "Alart"); return; //MessageBox.Show ("Error Code:-11001 " + ex.Message); } }
private void Button3_Click(object sender, EventArgs e) { try { int X = 0; if (txtFileName.Text == "") { Ep.SetError(txtFileName, "please select/Enter fileName....."); txtFileName.Focus(); return; } if (ComboBox2.Text == "") { Ep.SetError(ComboBox2, "please select Engine File....."); ComboBox2.Focus(); return; } if (ComboBox3.Text == "") { Ep.SetError(ComboBox3, "please select Sequence File....."); ComboBox3.Focus(); return; } if (ComboBox4.Text == "") { Ep.SetError(ComboBox4, "please select Limit File....."); ComboBox4.Focus(); return; } if (ComboBox5.Text == "") { Ep.SetError(ComboBox5, "please select Correction Standard....."); ComboBox5.Focus(); return; } if (ComboBox6.Text == "") { Ep.SetError(ComboBox6, "please Test Type Standard....."); ComboBox6.Focus(); return; } for (X = 1; X < (DGPrj.RowCount); X++) { if (DGPrj[1, X].Value == null) { Ep.SetError(DGPrj, "please Enter the Value ....."); DGPrj.Focus(); return; } else { Ep.Clear(); } } Format_Cells(); X = 0; flg_New = true; while (X < PrjGV.RowCount - 1) { if (txtFileName.Text == PrjGV[0, X].Value.ToString()) { flg_New = false; Rw = PrjGV.CurrentRow.Index; break; } else { flg_New = true; } X++; } Rw = PrjGV.CurrentRow.Index; if (flg_New == false) { Global.Open_Connection("General", "con"); MySqlCommand cmd = new MySqlCommand(); cmd.CommandText = "UPDATE tblProject SET " + " EngFile = '" + ComboBox2.Text + "'," + " ProgFile = '" + ComboBox3.Text + "'," + " LimitFile = '" + ComboBox4.Text + "'," + " CorrFile = '" + ComboBox5.Text + "'," + " Test_Type = '" + ComboBox6.Text + "'," + " R_power = '" + DGPrj[1, 0].Value.ToString() + "'," + " R_rpm = '" + DGPrj[1, 1].Value.ToString() + "'," + " MT_Torque = '" + DGPrj[1, 2].Value.ToString() + "'," + " MT_rpm = '" + DGPrj[1, 3].Value.ToString() + "'," + " Fly_rpm = '" + DGPrj[1, 4].Value.ToString() + "'," + " Idle_rpm = '" + DGPrj[1, 5].Value.ToString() + "'," + " Max_Tq = '" + DGPrj[1, 6].Value.ToString() + "'," + " Tq_Range = '" + DGPrj[1, 7].Value.ToString() + "'," + " PTO_Ratio = '" + DGPrj[1, 8].Value.ToString() + "'," + " PM_Log = '" + DGPrj[1, 9].Value.ToString() + "'" + " WHERE ProjectFile = '" + txtFileName.Text + "'"; cmd.Connection = Global.con; cmd.ExecuteNonQuery(); Load_DataGrid(); MessageBox.Show("File Updated ....."); } else if (flg_New == true) { Global.Open_Connection("General", "con"); MySqlCommand cmd = new MySqlCommand(); cmd.CommandText = "INSERT INTO tblProject VALUES ('" + txtFileName.Text + "','" + ComboBox2.Text + "','" + ComboBox3.Text + "','" + ComboBox4.Text + "','" + ComboBox5.Text + "','" + ComboBox6.Text + "','" + DGPrj[1, 0].Value + "','" + DGPrj[1, 1].Value + "','" + DGPrj[1, 2].Value + "','" + DGPrj[1, 3].Value + "','" + DGPrj[1, 4].Value + "','" + DGPrj[1, 5].Value + "','" + DGPrj[1, 6].Value + "','" + DGPrj[1, 7].Value + "','" + DGPrj[1, 8].Value + "','" + DGPrj[1, 9].Value + "')"; cmd.Connection = Global.con; cmd.ExecuteNonQuery(); Load_DataGrid(); MessageBox.Show("File Saved ....."); } } catch (Exception ex) { MessageBox.Show("Error Code:- 11004" + ex.Message); } }
private void EngDialog_Load(object sender, EventArgs e) { try { TextBox1.Text = String.Empty; Global.Open_Connection("gen_db", "con"); MySqlCommand cmd1 = new MySqlCommand("SELECT * FROM TbSys WHERE FileName = 'EngNo'", Global.con); MySqlDataReader Rd1 = cmd1.ExecuteReader(); while (Rd1.Read()) { TextBox1.Text = DateTime.Now.ToString("dd_MM_yyyy"); //Rd1.GetValue(1).ToString(); TextBox2.Text = Rd1.GetValue(2).ToString(); TextBox3.Text = Rd1.GetValue(3).ToString(); TextBox4.Text = Rd1.GetValue(4).ToString(); TextBox5.Text = Rd1.GetValue(5).ToString(); TextBox6.Text = Rd1.GetValue(6).ToString(); PrjCombo.Text = Rd1.GetValue(7).ToString(); if (Rd1.GetValue(8).ToString() == "True") { checkBox1.CheckState = CheckState.Checked; } else { checkBox1.CheckState = CheckState.Unchecked; } if (Rd1.GetValue(9).ToString() == "True") { checkBox2.CheckState = CheckState.Checked; } else { checkBox2.CheckState = CheckState.Unchecked; } if (Rd1.GetValue(10).ToString() == "True") { checkBox3.CheckState = CheckState.Checked; } else { checkBox3.CheckState = CheckState.Unchecked; } if (Rd1.GetValue(11).ToString() == "True") { checkBox4.CheckState = CheckState.Checked; } else { checkBox4.CheckState = CheckState.Unchecked; } if (Rd1.GetValue(12).ToString() == "True") { checkBox5.CheckState = CheckState.Checked; } else { checkBox5.CheckState = CheckState.Unchecked; } if (Rd1.GetValue(13).ToString() == "True") { rd_New.Checked = true; } else { rd_New.Checked = false; } if (Rd1.GetValue(14).ToString() == "True") { rd_Last.Checked = true; } else { rd_Last.Checked = false; } if (Rd1.GetValue(15).ToString() == "True") { rd_smooth.Checked = true; } else { rd_smooth.Checked = false; } if (Rd1.GetValue(16).ToString() == "True") { rd_standard.Checked = true; } else { rd_standard.Checked = false; } textBox7.Text = Rd1.GetValue(17).ToString(); textBox8.Text = Rd1.GetValue(18).ToString(); textBox13.Text = Rd1.GetValue(19).ToString(); HzCombo.Text = Rd1.GetValue(20).ToString(); TextBox9.Text = DateTime.Now.ToString("dd/MM/yyyy"); string ST = (Global.sysIn[10]); long Mn = (Convert.ToInt32(ST.Substring(0, 1)) * 60) + Convert.ToInt32(ST.Substring(2)); long Tm; Tm = (Convert.ToInt16(DateTime.Now.Hour.ToString()) * 60) + Convert.ToInt16(DateTime.Now.Minute.ToString()); if ((Tm > Mn) && (Tm <= (Mn + 480))) { TextBox10.Text = "A"; } else if ((Tm > (Mn + 480)) && (Tm <= (Mn + 960))) { TextBox10.Text = "B"; } else { TextBox10.Text = "C"; } } Rd1.Close(); Global.con.Close(); Fill_Combo(); } catch (Exception ex) { Global.Create_OnLog(ex.Message + " : EngDialog_Load....", "Alart"); } }
private void LoadParameter_Arr() { int I = 0; InV[0] = ipVal1; InV[1] = ipVal2; InV[2] = ipVal3; InV[3] = ipVal4; InV[4] = ipVal5; InV[5] = ipVal6; InV[6] = ipVal7; InV[7] = ipVal8; InV[8] = ipVal9; InV[9] = ipVal10; InV[10] = ipVal11; InV[11] = ipVal12; InV[12] = ipVal13; InV[13] = ipVal14; InV[14] = ipVal15; InV[15] = ipVal16; InV[16] = ipVal17; InV[17] = ipVal18; InV[18] = ipVal19; InV[19] = ipVal20; InV[20] = ipVal21; InV[21] = ipVal22; InV[22] = ipVal23; InV[23] = ipVal24; InV[24] = ipVal25; InV[25] = ipVal26; InV[26] = ipVal27; InV[27] = ipVal28; InV[28] = ipVal29; InV[29] = ipVal30; InV[30] = ipVal31; InV[31] = ipVal32; InV[32] = ipVal33; InV[33] = ipVal34; InV[34] = ipVal35; InV[35] = ipVal36; InV[36] = ipVal37; InV[37] = ipVal38; InV[38] = ipVal39; InV[39] = ipVal40; InV[40] = ipVal41; InV[41] = ipVal42; InV[42] = ipVal43; InV[43] = ipVal44; InV[44] = ipVal45; InV[45] = ipVal46; InV[46] = ipVal47; InV[47] = ipVal48; //InV[48] = ipVal36; //InV[49] = ipVal37; //InV[50] = ipVal38; //InV[51] = ipVal39; //InV[52] = ipVal40; //InV[53] = ipVal41; //InV[54] = ipVal42; //InV[55] = ipVal56; //InV[56] = ipVal57; //InV[57] = ipVal58; //InV[58] = ipVal59; //InV[59] = ipVal60; //InV[60] = ipVal61; //InV[61] = ipVal62; //InV[62] = ipVal63; //InV[63] = ipVal64; //InV[64] = ipVal65; //InV[65] = ipVal66; //InV[66] = ipVal67; //InV[67] = ipVal68; //InV[68] = ipVal69; //InV[69] = ipVal70; try { Global.Rd_Confg(); Global.Open_Connection("gen_db", "con"); MySqlCommand cmd = new MySqlCommand("SELECT * FROM tb_scrn ORDER BY N", Global.con); MySqlDataReader Rd = cmd.ExecuteReader(); int x = 0; while (Rd.Read()) { if (x > 47) { break; } Global.scrn_Par[x] = Rd.GetValue(1).ToString(); x += 1; } Rd.Close(); Global.con.Close(); for (I = 0; I <= 47; I++) { InV[I].Invoke(new Action(() => InV[I].P_Name = Global.PSName[int.Parse(Global.scrn_Par[I])].ToString())); if (InV[I].P_Name.Substring(0, 1) == "P") { InV[I].Invoke(new Action(() => InV[I].BackColor = Color.Silver)); } else if ((InV[I].P_Name.Substring(0, 1) == "T") || (InV[I].P_Name.Substring(0, 1) == "R")) { InV[I].Invoke(new Action(() => InV[I].BackColor = Color.DarkGray)); } else { InV[I].Invoke(new Action(() => InV[I].BackColor = Color.Gainsboro)); } //InV[I].Invoke(new Action(() => InV[I].BackColor = Color.Gainsboro)); InV[I].Invoke(new Action(() => InV[I].P_Color = Color.Navy)); //.MediumBlue)); InV[I].Invoke(new Action(() => InV[I].U_Color = Color.Black)); InV[I].Invoke(new Action(() => InV[I].colFont = new System.Drawing.Font("Book Antiqua", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))))); InV[I].Invoke(new Action(() => InV[I].P_Font = new System.Drawing.Font("Book Antiqua", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))))); InV[I].Invoke(new Action(() => InV[I].U_Font = new System.Drawing.Font("Book Antiqua", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))))); if (InV[I].P_Name == "Not_Prog") { InV[I].P_Name = ""; InV[I].P_Unit = ""; InV[I].Invoke(new Action(() => InV[I].colFillColor = Color.LightGray)); InV[I].Invoke(new Action(() => InV[I].colForeColor = Color.LightGray)); } else { InV[I].Invoke(new Action(() => InV[I].P_Name = Global.PSName[int.Parse(Global.scrn_Par[I])].ToString())); InV[I].Invoke(new Action(() => InV[I].P_Unit = Global.PUnit[int.Parse(Global.scrn_Par[I])].ToString())); InV[I].colFillColor = Color.ForestGreen; InV[I].colForeColor = Color.White; } } Init_Gantner(); Init_TCP_Port(); //t1 = Task.Run(() => { Global.Capture_fData(); }); //t1 = Task.Run(() => { clsADAM6000.Read_AdamValues6018(); }); //t2 = Task.Run(() => { clsADAM6000.Read_AdamValues6017(); }); GantnerThread = new Thread(new ThreadStart(Gantner_Thread)); GantnerThread.Start(); //ADAM6018Thread = new Thread(new ThreadStart(ADAM6018_Thread)); //ADAM6018Thread.Start(); //ADAM6017Thread = new Thread(new ThreadStart(ADAM6017_Thread)); //ADAM6017Thread.Start(); Global.Create_OnLog("Load_Arr()", "Normal "); LoadDgView(); tmrRead.Start(); timer1.Start(); } catch (Exception ex) { Global.Create_OnLog("Load_Arr()", "Alart"); //MessageBox.Show("Error in frmMain: Load_Arr(): " + ex.Message); } }
private void Create_Endurance() { Excel.Application xlApp; Excel.Workbook xlWorkBook; Excel.Worksheet xlWorkSheet; Process[] prs = Process.GetProcesses(); foreach (Process pr in prs) { if (pr.ProcessName == "EXCEL") { pr.Kill(); } } try { String[] Enduno = new String[30]; String[] Enduhead = new String[30]; String[] Enduunit = new String[30]; string cell1, cell2; object misValue = System.Reflection.Missing.Value; int i, k; int j, rx; xlApp = new Excel.Application(); xlWorkBook = xlApp.Workbooks.Open(Global.PATH + "Endurance.xlsx", 0, misValue, 4, "", "", true, Microsoft.Office.Interop.Excel.XlPlatform.xlWindows, "\t", false, false, 0, true, 1, 0); xlWorkSheet = (Excel.Worksheet)xlWorkBook.Worksheets.get_Item("Endurance"); xlWorkSheet.get_Range("B12", "U2000").Clear(); //------------------------- xlWorkSheet.Cells[2, 19] = DateTime.Now.ToString("dd/MM/yyyy"); xlWorkSheet.Cells[3, 19] = Global.T_CellNo; //----------------------- xlWorkSheet.Cells[4, 4] = Global.EngType; xlWorkSheet.Cells[5, 4] = Global.EngNo; xlWorkSheet.Cells[6, 4] = Global.Bor; xlWorkSheet.Cells[7, 4] = Global.Strk; xlWorkSheet.Cells[8, 4] = Global.NCyl; xlWorkSheet.Cells[9, 4] = Global.Svol; //------------------------ xlWorkSheet.Cells[5, 8] = Global.EnginerNm; xlWorkSheet.Cells[6, 8] = Global.OperatorNm; xlWorkSheet.Cells[7, 8] = Global.TestRef; xlWorkSheet.Cells[8, 8] = Global.SGrv; //-------------------------- //------------------------ if (Global.flg_Radiator == true) { xlWorkSheet.Cells[5, 12] = "YES"; } else { xlWorkSheet.Cells[5, 12] = "NO"; } if (Global.flg_Fan == true) { xlWorkSheet.Cells[6, 12] = "YES"; } else { xlWorkSheet.Cells[6, 12] = "NO"; } if (Global.flg_AirCln == true) { xlWorkSheet.Cells[7, 12] = "YES"; } else { xlWorkSheet.Cells[7, 12] = "NO"; } if (Global.flg_Silincer == true) { xlWorkSheet.Cells[8, 12] = "YES"; } else { xlWorkSheet.Cells[8, 12] = "NO"; } ////-------------------------- //---------------------------------- xlWorkSheet.Cells[5, 16] = Global.CStrtTm; xlWorkSheet.Cells[6, 16] = Global.CStopTm; xlWorkSheet.Cells[8, 16] = Global.cumhours; Global.Open_Connection("General", "con"); MySqlDataAdapter adp2 = new MySqlDataAdapter("Select * from Tb_Endu ", Global.con); DataSet ds2 = new DataSet(); adp2.Fill(ds2); prgT.Visible = true; prgT.Value = (int)1; prgT.Caption = "Wait Data For Transfer ......."; k = 20; for (i = 0; i <= k - 1; i++) { Enduno[i] = ds2.Tables[0].Rows[i].ItemArray[1].ToString(); Enduhead[i] = ds2.Tables[0].Rows[i].ItemArray[2].ToString(); xlWorkSheet.Cells[10, i + 2] = ds2.Tables[0].Rows[i].ItemArray[2].ToString(); Enduunit[i] = ds2.Tables[0].Rows[i].ItemArray[3].ToString(); xlWorkSheet.Cells[11, i + 2] = ds2.Tables[0].Rows[i].ItemArray[3].ToString(); } k = i; adp2.Dispose(); ds2.Dispose(); Global.con.Close(); Global.Open_Connection("Data", "conData"); MySqlDataAdapter adp1 = new MySqlDataAdapter("Select * from " + Global.Eng_FileNm + " Order by Pn", Global.conData); DataSet ds1 = new DataSet(); adp1.Fill(ds1); rx = ds1.Tables[0].Rows.Count; prgT.Maximum = rx + 1; prgT.Value = (int)1; for (int m = 0; m <= rx - 1; m++) { prgT.Value = (int)(m + 1); for (int n = 0; n <= k - 1; n++) { xlWorkSheet.Cells[m + 12, n + 2] = ds1.Tables[0].Rows[m].ItemArray[int.Parse(Enduno[n])].ToString(); } prgT.Value = m; } Global.conData.Close(); prgT.Caption = "Data Transfer Over ......."; //cell3 = "B8"; //cell4 = "AB10"; cell1 = "B12"; cell2 = "U" + (rx + 12); xlWorkSheet.get_Range(cell1, cell2).Font.Size = 11; //style.FontStyle.Color = Color.White; xlWorkSheet.get_Range(cell1, cell2).Font.ColorIndex = 5; xlWorkSheet.get_Range(cell1, cell2).Font.Name = "Book Antiqua"; xlWorkSheet.get_Range(cell1, cell2).Borders.ColorIndex = 15; xlWorkSheet.get_Range(cell1, cell2).Borders.LineStyle = Excel.XlBorderWeight.xlHairline; xlWorkSheet.get_Range(cell1, cell2).BorderAround(Excel.XlLineStyle.xlDouble, Excel.XlBorderWeight.xlThin, Microsoft.Office.Interop.Excel.XlColorIndex.xlColorIndexAutomatic, Microsoft.Office.Interop.Excel.XlColorIndex.xlColorIndexAutomatic); //xlWorkSheet.get_Range(cell3, cell4).Borders.LineStyle = Excel.XlBorderWeight.xlHairline; //xlWorkSheet.get_Range(cell3, cell4).Font.Size = 11; //xlWorkSheet.get_Range(cell3, cell4).Font.Bold = false; //xlWorkSheet.get_Range(cell3, cell4).Borders.ColorIndex = 15; //xlWorkSheet.get_Range(cell3, cell4).Font.ColorIndex = 9; ////xlWorkSheet.get_Range("B9", "W9").Font.ColorIndex = 5; //xlWorkSheet.get_Range("B10", "W10").Font.ColorIndex = 1; //xlWorkSheet.get_Range(cell3, cell4).Font.Name = "Book Antiqua"; //xlWorkSheet.get_Range(cell3, cell4).BorderAround(Excel.XlLineStyle.xlDouble, Excel.XlBorderWeight.xlThin, Excel.XlColorIndex.xlColorIndexAutomatic, Excel.XlColorIndex.xlColorIndexAutomatic); xlWorkBook.SaveAs((object)(Global.DataPath + "Endu_" + Global.Eng_FileNm.Substring(4)), misValue, misValue, misValue, false, misValue, Microsoft.Office.Interop.Excel.XlSaveAsAccessMode.xlShared, misValue, misValue, misValue, misValue, misValue); xlApp.Visible = true; } catch (Exception ex) { MessageBox.Show("Error Code:- 17007", ex.Message); } }
private void frmProject_Load(object sender, EventArgs e) { try { txtFileName.Text = ""; ComboBox2.Items.Clear(); ComboBox3.Items.Clear(); ComboBox4.Items.Clear(); DGPrj.RowCount = 10; DGPrj.RowTemplate.Height = 30; foreach (DataGridViewColumn colm in DGPrj.Columns) { colm.SortMode = DataGridViewColumnSortMode.NotSortable; } DGPrj[0, 0].Value = "Engine Rated Power (kW):"; DGPrj[0, 1].Value = "@ PTO rpm :"; DGPrj[0, 2].Value = "PTO Rated Torque (Nm):"; DGPrj[0, 3].Value = "@ PTO rpm :"; DGPrj[0, 4].Value = "PTO Flyup RPM:"; DGPrj[0, 5].Value = "PTO Idle RPM:"; DGPrj[0, 6].Value = "PTO Max Torque(Nm):"; DGPrj[0, 7].Value = "Engine Torque Range(1000/2000) Nm:"; DGPrj[0, 8].Value = "PTO Ratio: "; DGPrj[0, 9].Value = "Log PM' Data After Eng.OFF(secs)"; DGPrj.Columns[1].DefaultCellStyle.ForeColor = Color.Red; ComboBox3.Items.Clear(); ComboBox3.Refresh(); Global.Open_Connection("Sequence", "conSeq"); DataTable dt = Global.conSeq.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, new object[] { null, null, null, "TABLE" }); for (int i = 0; i < dt.Rows.Count; i++) { ComboBox3.Items.Add(dt.Rows[i]["TABLE_NAME"].ToString()); } Global.conSeq.Close(); ComboBox4.Items.Clear(); ComboBox4.Refresh(); Global.Open_Connection("Limit", "conLim"); dt = Global.conLim.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, new object[] { null, null, null, "TABLE" }); for (int i = 0; i < dt.Rows.Count; i++) { ComboBox4.Items.Add(dt.Rows[i]["TABLE_NAME"].ToString()); } Global.conLim.Close(); Global.Open_Connection("General", "con"); Adp = new MySqlDataAdapter("SELECT * FROM tblEngine", Global.con); ds = new DataSet(); Adp.Fill(ds); int x = 0; ComboBox2.Items.Clear(); for (x = 0; x <= (ds.Tables[0].Rows.Count - 1); x++) { ComboBox2.Items.Add(ds.Tables[0].Rows[x].ItemArray[0]); } ds.Dispose(); Adp.Dispose(); Global.Open_Connection("General", "con"); Adp = new MySqlDataAdapter("Select * from tblProject", Global.con); ds = new DataSet(); Adp.Fill(ds); PrjGV.DataSource = ds.Tables[0]; PrjGV.Columns[0].Width = 100; PrjGV.Columns[1].Width = 100; PrjGV.Columns[2].Width = 100; PrjGV.Columns[3].Width = 100; PrjGV.Columns[4].Width = 100; PrjGV.Columns[5].Width = 100; PrjGV.Columns[6].Width = 60; PrjGV.Columns[7].Width = 60; PrjGV.Columns[8].Width = 60; PrjGV.Columns[9].Width = 60; PrjGV.Columns[10].Width = 60; PrjGV.Columns[11].Width = 60; PrjGV.Columns[12].Width = 60; PrjGV.Columns[13].Width = 60; PrjGV.Columns[14].Width = 60; PrjGV.Columns[15].Width = 60; foreach (DataGridViewColumn colm in PrjGV.Columns) { colm.SortMode = DataGridViewColumnSortMode.NotSortable; } Adp.Update(ds.Tables[0]); Load_InCell(); } catch (Exception ex) { MessageBox.Show("Error Code:-11001 " + ex.Message); } }
private void loadInCell() { Rw = dgPConf.CurrentRow.Index; cmbDeviceName.Text = dgPConf[1, Rw].Value.ToString(); cmbPort.Text = dgPConf[2, Rw].Value.ToString(); cmbBaudRate.Text = dgPConf[3, Rw].Value.ToString(); cmbParity.Text = dgPConf[4, Rw].Value.ToString(); cmbStopBit.Text = dgPConf[5, Rw].Value.ToString(); txtInstID.Text = dgPConf[6, Rw].Value.ToString(); txtStartAdd.Text = dgPConf[7, Rw].Value.ToString(); txtNReads.Text = dgPConf[8, Rw].Value.ToString(); String st = dgPConf[9, Rw].Value.ToString(); foreach (DataGridViewRow row in dgPConf.Rows) { if (st == "True") { chkSelect.Text = "Selected"; chkSelect.CheckState = CheckState.Checked; dgPConf.Rows[Rw].DefaultCellStyle.BackColor = Color.Gainsboro; } else if (st == "False") { chkSelect.Text = "Not Selected"; chkSelect.CheckState = CheckState.Unchecked; dgPConf.Rows[Rw].DefaultCellStyle.BackColor = Color.WhiteSmoke; } } switch (Rw) { case 6: case 7: case 8: case 9: case 10: case 11: panel2.Enabled = true; panel3.Enabled = false; break; case 1: panel2.Enabled = false; panel3.Enabled = true; Global.Open_Connection("gen_db", "con"); int I = 0; MySqlDataAdapter Dap = new MySqlDataAdapter("SELECT * FROM TbSys WHERE FileName = 'ADAMGroup01'", Global.con); DataSet ds = new DataSet(); Dap.Fill(ds); for (I = 0; I < 15; I++) { AdamArr[I] = ds.Tables[0].Rows[0].ItemArray[I + 1].ToString(); } txtM1.Text = AdamArr[0]; ADAMType1.Text = AdamArr[1]; ADAMRange1.Text = AdamArr[2]; txtM2.Text = AdamArr[3]; ADAMType2.Text = AdamArr[4]; ADAMRange2.Text = AdamArr[5]; txtM3.Text = AdamArr[6]; ADAMType3.Text = AdamArr[7]; ADAMRange3.Text = AdamArr[8]; txtM4.Text = AdamArr[9]; ADAMType4.Text = AdamArr[10]; ADAMRange4.Text = AdamArr[11]; txtM5.Text = AdamArr[12]; ADAMType5.Text = AdamArr[13]; ADAMRange5.Text = AdamArr[14]; break; case 2: panel2.Enabled = false; panel3.Enabled = true; Global.Open_Connection("gen_db", "con"); int I1 = 0; MySqlDataAdapter Dap1 = new MySqlDataAdapter("SELECT * FROM TbSys WHERE FileName = 'ADAMGroup02'", Global.con); DataSet ds1 = new DataSet(); Dap1.Fill(ds1); for (I1 = 0; I1 < 15; I1++) { AdamArr[I1] = ds1.Tables[0].Rows[0].ItemArray[I1 + 1].ToString(); } txtM1.Text = AdamArr[0]; ADAMType1.Text = AdamArr[1]; ADAMRange1.Text = AdamArr[2]; txtM2.Text = AdamArr[3]; ADAMType2.Text = AdamArr[4]; ADAMRange2.Text = AdamArr[5]; txtM3.Text = AdamArr[6]; ADAMType3.Text = AdamArr[7]; ADAMRange3.Text = AdamArr[8]; txtM4.Text = AdamArr[9]; ADAMType4.Text = AdamArr[10]; ADAMRange4.Text = AdamArr[11]; txtM5.Text = AdamArr[12]; ADAMType5.Text = AdamArr[13]; ADAMRange5.Text = AdamArr[14]; break; default: panel2.Enabled = false; panel3.Enabled = false; break; } }
private void frmLEfiles_Load(object sender, EventArgs e) { try { if (Global.Prj[3] == null) { MessageBox.Show("Error : Please. Select the Project ...."); return; } else { label3.Text = Global.Prj[3]; Global.Open_Connection("lim_db", "ConLim"); MySqlDataAdapter adp = new MySqlDataAdapter("SELECT * FROM " + Global.Prj[3], Global.conLim); DataSet ds = new DataSet(); adp.Fill(ds); //LimGV.ColumnCount = ds.Tables[0].Columns.Count; LimGV.DataSource = ds.Tables[0]; LimGV.Columns[0].Width = 30; LimGV.Columns[1].Width = 100; LimGV.Columns[2].Width = 80; LimGV.Columns[3].Width = 80; LimGV.Columns[4].Width = 80; LimGV.Columns[5].Width = 80; LimGV.Columns[6].Width = 80; LimGV.Columns[7].Width = 80; LimGV.Columns[8].Width = 80; LimGV.DefaultCellStyle.ForeColor = Color.Blue; LimGV.DefaultCellStyle.Font = new System.Drawing.Font("Calibri", 9F); //, ((System.Drawing.FontStyle)((System.Drawing.FontStyle.Bold | System.Drawing.FontStyle.Italic))), System.Drawing.GraphicsUnit.Point, ((byte)(0))); LimGV.ColumnHeadersDefaultCellStyle.Font = new System.Drawing.Font("Calibri", 10F, ((System.Drawing.FontStyle)(System.Drawing.FontStyle.Regular))); adp.Dispose(); ds.Dispose(); Global.conLim.Close(); foreach (DataGridViewColumn colm in LimGV.Columns) { colm.SortMode = DataGridViewColumnSortMode.NotSortable; } } if (Global.Prj[1] == null) { MessageBox.Show("Error : Please. Select the Project ...."); return; } else { label5.Text = Global.Prj[2]; label2.Text = Global.Prj[1]; Global.Open_Connection("gen_db", "con"); MySqlDataAdapter adp = new MySqlDataAdapter("SELECT * FROM tblEngine WHERE EngineFile = '" + Global.Prj[1] + "'", Global.con); DataSet ds = new DataSet(); adp.Fill(ds); EngGV.DataSource = ds.Tables[0]; EngGV.DefaultCellStyle.ForeColor = Color.Blue; EngGV.DefaultCellStyle.Font = new System.Drawing.Font("Calibri", 9F); EngGV.ColumnHeadersDefaultCellStyle.Font = new System.Drawing.Font("Calibri", 10F, ((System.Drawing.FontStyle)(System.Drawing.FontStyle.Regular))); adp.Dispose(); ds.Dispose(); Global.con.Close(); foreach (DataGridViewColumn colm in EngGV.Columns) { colm.SortMode = DataGridViewColumnSortMode.NotSortable; } } } catch (Exception ex) { MessageBox.Show("Error Code: -6001 " + ex.Message); } }
private void Check_File_Validation() { try { if (Global.EngNo == String.Empty) { MessageBox.Show("Engine No. Not Entered ......., "); } else { Global.Open_Connection("gen_db", "con"); MySqlCommand cmd = new MySqlCommand("SELECT * FROM tblProject WHERE ProjectFile = '" + Global.PrjNm + "'", Global.con); MySqlDataReader Rd = cmd.ExecuteReader(); int x = 0; while (Rd.Read()) { for (x = 0; x < (Rd.FieldCount - 1); x++) { Global.Prj[x] = Rd.GetValue(x).ToString(); } } Global.TestTyp = Global.Prj[5]; Global.cumhours = "0000.00.00"; Global.Open_Connection("gen_db", "con"); MySqlCommand cmd1 = new MySqlCommand("SELECT * FROM tblEngine", Global.con); MySqlDataReader Rd1 = cmd1.ExecuteReader(); x = 0; while (Rd1.Read()) { if (Global.Prj[1] == Rd1.GetValue(0).ToString()) { f_Found = true; break; } x += 1; Rd1.Close(); } if (f_Found == false) { MessageBox.Show("Engine File Not Found ....... "); return; } Global.con.Close(); // ************************** x = 0; Global.Open_Connection("lim_db", "conLim"); MySqlCommand cmd2 = new MySqlCommand("SELECT TABLE_NAME FROM lim_db.INFORMATION_SCHEMA.TABLES", Global.conLim); using (MySqlDataReader reader = cmd2.ExecuteReader()) { if (Global.Prj[3] == ((string)reader["TABLE_NAME"])) { f_Found = true; } x += 1; reader.Close(); } if (f_Found == false) { MessageBox.Show("Limit File Not Found ....... "); return; } cmd2.Dispose(); Global.conLim.Close(); //********************************** x = 0; Global.Open_Connection("seq_db", "conSeq"); MySqlCommand cmd3 = new MySqlCommand("SELECT TABLE_NAME FROM seq_db.INFORMATION_SCHEMA.TABLES", Global.conSeq); using (MySqlDataReader reader = cmd3.ExecuteReader()) { if (Global.Prj[2] == ((string)reader["TABLE_NAME"])) { f_Found = true; } x += 1; reader.Close(); } if (f_Found == false) { MessageBox.Show("Sequence File Not Found ....... "); return; } cmd3.Dispose(); Global.conSeq.Close(); } } catch (Exception ex) { Global.Create_OnLog(ex.Message + " : Check Validation EngDialog....", "Alart"); } }