public void Auto_check_CheckedChanged(object sender, EventArgs e) { //Auto_check.Checked = true; if (Auto_check.Checked) { Auto_check.Text = "set"; Auto_check.ForeColor = Color.Green; new SetDataTime().Show(); // open the Set date time form } else { Auto_check.Text = "unset"; Auto_check.ForeColor = Color.Red; DB.IsGenerateEOD_report = false; // auto generate report off /* try { * * string UpdatesConfig = File.ReadAllText("E:/config.txt"); * * string replaceStr = UpdatesConfig.Replace("ENABLE", "DISABLE"); * * File.WriteAllText("E:/config.txt", replaceStr); * } * catch (Exception ex) * { * Debug.WriteLine("File can't write :" + ex); * * }*/ String QueryStr; OleDbCommand cmd; try { SQL_SERVER.Set_Sql_Server_Conn(); SQL_SERVER.Open_Sql_Server_Conn(); QueryStr = "UPDATE [Auto_EOD_Config] SET [AUTOEOD]='DISABLE' where [ID]=1"; SQL_SERVER.ExecuteNonQuery(QueryStr); } catch (Exception ex) { Debug.WriteLine("Not Update data from Auto_EOD_Config table :" + ex); } //UpdatesConfig.Replace(UpdatesConfig.Substring(UpdatesConfig.IndexOf("<AUTOEOD>") + 9, (UpdatesConfig.IndexOf("</AUTOEOD>") - UpdatesConfig.IndexOf("<AUTOEOD>") - 9)),"" Display.ShowMessageBox("Off Automatic Day Close", 4); } }
private void on_off_Click(object sender, EventArgs e) { if (on_off.Text == "OFF") { on_off.Text = "ON"; } else if (on_off.Text == "ON") { on_off.Text = "OFF"; } if (on_off.Text == "ON") { on_off.ForeColor = Color.Green; new SetDataTime().Show(); } else if (on_off.Text == "OFF") { on_off.ForeColor = Color.Red; DB.IsGenerateEOD_report = false; SQL_SERVER.Open_Sql_Server_Conn(); String QueryStr; try { QueryStr = "UPDATE [Auto_EOD_Config] SET [AUTOEOD]='DISABLE' where [ID]=1"; SQL_SERVER.ExecuteNonQuery(QueryStr); //SQL_SERVER.ExecuteNonQuery(QueryStr); } catch (Exception ex) { Debug.WriteLine("Not Update data from Auto_EOD_Config table :" + ex); } SQL_SERVER.Close_Sql_Sever_Conn(); //UpdatesConfig.Replace(UpdatesConfig.Substring(UpdatesConfig.IndexOf("<AUTOEOD>") + 9, (UpdatesConfig.IndexOf("</AUTOEOD>") - UpdatesConfig.IndexOf("<AUTOEOD>") - 9)),"" Display.ShowMessageBox("Off Automatic Day Close", 4); } }
private void Ok_btn_Click(object sender, EventArgs e) { hours = hours_txt_box.Text.ToString().Trim(); minutes = minutes_txt_box.Text.ToString().Trim(); if ((hours != null && hours != "") && (minutes != null && minutes != "") && (IsselectedAm || IsselectedPm)) { if (hours.Length == 1) { hours = "0" + hours; } if (minutes.Length == 1) { minutes = "0" + minutes; } /* try * { * * UpdatesConfig = File.ReadAllText("E:/config.txt"); * * UpdatesConfig = UpdatesConfig.Replace("DISABLE", "ENABLE"); * UpdatesConfig = UpdatesConfig.Replace((UpdatesConfig.Substring(UpdatesConfig.IndexOf("<HOURS>") + 7, (UpdatesConfig.IndexOf("</HOURS>") - UpdatesConfig.IndexOf("<HOURS>") - 7))), hours + ""); * UpdatesConfig = UpdatesConfig.Replace((UpdatesConfig.Substring(UpdatesConfig.IndexOf("<MINUTES>") + 9, (UpdatesConfig.IndexOf("</MINUTES>") - UpdatesConfig.IndexOf("<MINUTES>") - 9))), minutes + ""); * UpdatesConfig = UpdatesConfig.Replace((UpdatesConfig.Substring(UpdatesConfig.IndexOf("<INTERVAL>") + 10, (UpdatesConfig.IndexOf("</INTERVAL>") - UpdatesConfig.IndexOf("<INTERVAL>") - 10))), interval + ""); * * File.WriteAllText("E:/config.txt", UpdatesConfig); * } * catch (Exception ex) { * Debug.WriteLine("File can't write (Not set time in file) :" + ex); * * }*/ String QueryStr; OleDbCommand cmd; try { SQL_SERVER.Set_Sql_Server_Conn(); SQL_SERVER.Open_Sql_Server_Conn(); //QueryStr = @"UPDATE Auto_EOD_Config SET AUTOEOD='ENABLE', HOURS='" + hours + "', MINUTES='" + minutes + "', INTERVAL='"+interval+"' WHERE ID=1"; QueryStr = @"UPDATE [Auto_EOD_Config] Set [AUTOEOD] = 'ENABLE', [HOURS]='" + hours + "', [MINUTES]='" + minutes + "', [INTERVAL]='" + interval + "' WHERE [ID]=1;"; SQL_SERVER.ExecuteNonQuery(QueryStr); /* cmd = SQL_SERVER.Set_Sql_Server_Cmd(QueryStr); * cmd.Parameters.AddWithValue("@enable","ENABLE"); * cmd.Parameters.AddWithValue("@hours",hours.ToString()); * cmd.Parameters.AddWithValue("@minutes", minutes.ToString()); * cmd.Parameters.AddWithValue("interval", interval.ToString()); * cmd.Parameters.AddWithValue("@id",1); * * cmd.ExecuteNonQuery();*/ } catch (Exception ex) { Debug.WriteLine("Not Update data from Auto_EOD_Config table :" + ex); } this.Hide(); //DB.IsGenerateEOD_report = false; //DB.IsGeneratePIC_Cash_report = false; // MessageBox.Show(hours+":"+minutes+":01"+" "+interval+" "+DateTime.Now.ToString("hh:mm:ss tt")); Display.ShowMessageBox("your time seted " + hours + ":" + minutes + " " + interval, 5); } else { Display.ShowMessageBox("Please set all fields", 5); } // this.Hide(); //form1.Auto_check.Checked = false; //form1.Auto_check.CheckedChanged += new EventHandler(CheckBox_Checked); // form1.Auto_check_CheckedChanged(null,null); //CheckBox check = (CheckBox)this.form1.Controls["Auto_check"]; }