示例#1
0
 private void LimCombo_Leave(object sender, EventArgs e)
 {
     try
     {
         Common.FormatCombo(LimCombo);
         if (LimCombo.Text.Length <= 0)
         {
             EP.SetError(LimCombo, "Type the File Name First...");
             LimCombo.Focus();
             return;
         }
         else if (LimCombo.Text.Length <= 5)
         {
             EP.SetError(LimCombo, "The name should be More than 5 Letters...");
             LimCombo.Focus();
         }
         else if (((LimCombo.Text.Substring(0, 4)) == "Lim_") || ((LimCombo.Text.Substring(0, 4)) == "LIM_") || ((LimCombo.Text.Substring(0, 4)) == "lim_"))
         {
             LimCombo.Text = "lim_" + (LimCombo.Text.Substring(4)).ToLower();
             EP.Clear();
         }
         else
         {
             LimCombo.Text = "lim_" + LimCombo.Text.ToLower();
             EP.Clear();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(" LimCombo_Leave @ Error Code:-7013 " + ex.Message);
     }
 }
示例#2
0
        private void mnuUpdate_Click(object sender, EventArgs e)
        {
            mnuNew.Enabled    = true;
            mnuDelete.Enabled = true;


            if (file_Exist == false)
            {
                try
                {
                    if (LimCombo.Text == "")
                    {
                        MessageBox.Show("Give the Name for New File....");
                        LimCombo.Focus();
                        return;
                    }
                    Common.Open_Connection("lim_db", "conLim");
                    MySqlCommand cmdTb = new MySqlCommand();
                    String       StrTb = " Pn Float Primary Key,ParameterName VARCHAR(30)," +
                                         " Lower1 VARCHAR(8), Low1 VARCHAR(8),High1 VARCHAR(8),Higher1 VARCHAR(8)," +
                                         " MinV VARCHAR(8),MaxV VARCHAR(8),Unit VARCHAR(10)";

                    cmdTb.CommandText = "CREATE TABLE " + LimCombo.Text.ToLower() + "(" + StrTb + ")";
                    cmdTb.Connection  = Common.conLim;
                    cmdTb.ExecuteNonQuery();
                    Common.conLim.Close();

                    int i = 0;
                    Common.Open_Connection("lim_db", "conLim");
                    MySqlCommand cmd = new MySqlCommand();
                    for (i = 0; i < limDGV.RowCount - 1; i++)
                    {
                        cmd.CommandText = "INSERT INTO " + LimCombo.Text.ToLower() + " VALUES ('" +
                                          limDGV[0, i].Value.ToString() + "','" +
                                          limDGV[1, i].Value.ToString() + "','" +
                                          limDGV[2, i].Value.ToString() + "','" +
                                          limDGV[3, i].Value.ToString() + "','" +
                                          limDGV[4, i].Value.ToString() + "','" +
                                          limDGV[5, i].Value.ToString() + "','" +
                                          limDGV[6, i].Value.ToString() + "','" +
                                          limDGV[7, i].Value.ToString() + "','" +
                                          limDGV[8, i].Value.ToString() + "')";
                        cmd.Connection = Common.conLim;
                        cmd.ExecuteNonQuery();
                    }
                    Common.conLim.Close();
                    //file_Exist = true;
                    Common.Create_OnLog("Normal", "New Limit  File Saved.....");

                    MessageBox.Show("File Saved .....");
                    Fill_comboBox();
                }
                catch (Exception ex)
                {
                    MessageBox.Show("mnuUpdate_Click New file @ Error Code:-12012" + ex.Message);
                }
            }
            else if (file_Exist == true)
            {
                try
                {
                    int Rw = 0;
                    Common.Open_Connection("lim_db", "conLim");
                    MySqlCommand cmd = new MySqlCommand();

                    for (Rw = 0; Rw <= (limDGV.RowCount - 2); Rw++)
                    {
                        int x = Convert.ToInt16(limDGV.Rows[Rw].Cells[0].Value);
                        cmd.CommandText = "UPDATE " + LimCombo.Text.ToLower() + " SET" +
                                          " Lower1 = '" + limDGV.Rows[Rw].Cells[2].Value.ToString() + "'," +
                                          " Low1 = '" + limDGV.Rows[Rw].Cells[3].Value.ToString() + "'," +
                                          " High1 = '" + limDGV.Rows[Rw].Cells[4].Value.ToString() + "'," +
                                          " Higher1 = '" + limDGV.Rows[Rw].Cells[5].Value.ToString() + "'" +
                                          " WHERE Pn = " + x;
                        cmd.Connection = Common.conLim;
                        cmd.ExecuteNonQuery();
                    }
                    Common.conLim.Close();
                    Common.Create_OnLog("Normal", "Limit  File Saved.....");
                    MessageBox.Show("New Changes are saved .....");
                    Fill_comboBox();
                }
                catch (Exception ex)

                {
                    MessageBox.Show("mnuUpdate_Click existing  file @  Error Code:-12012", ex.Message);
                }
            }
        }