Ejemplo n.º 1
0
        private void DGPrj_CellValueChanged(object sender, DataGridViewCellEventArgs e)
        {
            try
            {
                int    M   = DGPrj.CurrentRow.Index;
                string str = DGPrj[1, M].Value.ToString();
                if (!(string.IsNullOrEmpty(str)))
                {
                    char[] chars = str.ToCharArray();

                    for (int i = 0; i < str.Length; i++)
                    {
                        int code;
                        code = Convert.ToInt16(chars[i]);

                        if (!((!(code > 57 || code < 48)) || (code == 46)))
                        {
                            DGPrj[1, M].Value = str.Remove(i, 1);
                        }
                    }
                }
            }
            catch
            {
                DGPrj.Focus();
            }
        }
Ejemplo n.º 2
0
        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);
            }
        }