private void ComboBox1_Leave(object sender, EventArgs e) { try { if (ComboBox1.Text == "") { Erp.SetError(ComboBox1, "Type the File Name First..." + "Name Should Be More Than 5 Characters"); return; } if (ComboBox1.Text.Length <= 4) { Erp.SetError(ComboBox1, "Type the File Name First..." + "Name Should Be More Than 5 Characters"); ComboBox1.Focus(); ComboBox1.Text = ""; return; } Common.FormatCombo(ComboBox1); if (ComboBox1.Text.Length > 4) { switch ((ComboBox1.Text.Substring(0, 4))) { case "ENG_": ComboBox1.Text = "eng_" + (ComboBox1.Text.Substring(4)).ToLower(); Erp.Clear(); break; case "Eng_": ComboBox1.Text = "eng_" + (ComboBox1.Text.Substring(4)).ToLower(); Erp.Clear(); break; case "eng_": ComboBox1.Text = "eng_" + (ComboBox1.Text.Substring(4)).ToLower(); Erp.Clear(); break; default: ComboBox1.Text = "eng_" + ComboBox1.Text.ToLower(); Erp.Clear(); break; } } } catch (Exception ex) { MessageBox.Show("ComboBox1_Leave @ " + ex.Message); } }
private void mnuSave_Click(object sender, EventArgs e) { try { if (ComboBox1.Text == "") { Erp.SetError(ComboBox1, "Type the File Name First..." + "Name Should Be More Than 5 Characters"); return; } int x; for (x = 0; x <= (EngGView.RowCount - 1); x++) { if (ComboBox1.Text == EngGView[0, x].Value.ToString()) { flg_New = false; break; } else { flg_New = true; } } String strData = ""; if (ComboBox1.Text == "") { ComboBox1.Text = " "; } strData = strData + ComboBox1.Text + "', '"; strData = strData + "Diesel"; for (x = 1; x <= (EngGView.Columns.Count - 2); x++) { if ((DataGrid[1, x].Value) == null) { DataGrid[1, x].Value = "***"; } strData = strData + "', '" + DataGrid[1, x].Value.ToString(); } if (flg_New == false) { Common.Del_SqlTable("systb", ComboBox1.Text); //MySqlCommand cDelete = new MySqlCommand(); //cDelete.CommandText = "DELETE FROM tblEngine WHERE EngineFile = '" + ComboBox1.Text.ToLower() + "'"; //Common.Open_Connection("gen_db", "con"); //cDelete.Connection = Common.con; //cDelete.ExecuteNonQuery(); } Common.Open_Connection("gen_db", "con"); MySqlCommand cmd = new MySqlCommand(); cmd.CommandText = " INSERT INTO tblEngine VALUES ('" + strData + "')"; cmd.Connection = Common.con; cmd.ExecuteNonQuery(); MessageBox.Show("File saved ....."); Common.Create_OnLog("Normal", "Engine File Saved....."); Load_Datagrid(); } catch (Exception ex) { MessageBox.Show("mnuSave_Click @ Error Code:-11007 " + ex.Message); Common.Create_OnLog("Alart", "Engine File not Saved....."); } }