// Send message by udpating decade private void msg_send_button_Click(object sender, EventArgs e) { if (ready_to_send && msg_chat_box.Text.Trim().Length > 0) { string query = "select firstname from d_user where employeenumber = '" + this.employeenumber + "'"; ExcoODBC database = ExcoODBC.Instance; OdbcDataReader reader; database.Open(Database.DECADE_MARKHAM); reader = database.RunQuery(query); reader.Read(); string current_name = reader[0].ToString().Trim(); reader.Close(); // Encrypt Encrypter en = new Encrypter(); string encrypted = en.Encrypt(cleanse_apostrophe(msg_chat_box.Text)); query = "insert into d_msgtable (msg, fromemp, fromname, toemp, toname, msgtime, important, didread) values ('" + encrypted + "', '" + this.employeenumber + "', '" + current_name + "', '" + from_employee_number_g + "', '" + from_employee_name_g + "', '" + DateTime.Now.ToString() + "', '0', '0')"; if (passes_sql_check(msg_chat_box.Text)) { database = ExcoODBC.Instance; database.Open(Database.DECADE_MARKHAM); reader = database.RunQuery(query); refresh_conversation(from_employee_number_g, this.employeenumber); msg_clear_button.PerformClick(); reader.Close(); } } }
// Background check messages private bool has_unread_messages(string employeenumber) { string query = "select * from d_msgtable where toemp = '" + employeenumber + "' and didread = '0'"; ExcoODBC database2 = ExcoODBC.Instance; OdbcDataReader reader2; database2 = ExcoODBC.Instance; database2.Open(Database.DECADE_MARKHAM); reader2 = database2.RunQuery(query); reader2.Read(); try { Console.WriteLine(reader2[0].ToString()); if ((!alerted_people.Contains(reader2[1].ToString().Trim())) && notifications.Checked) { AlertBox alert = new AlertBox("Message recieved from " + reader2[2].ToString().Trim(), employeenumber); alerted_people.Add(reader2[1].ToString().Trim()); alert.Show(); reader2.Close(); query = "update d_msgtable set didread = '1' where toemp = '" + employeenumber + "'"; database2 = ExcoODBC.Instance; database2.Open(Database.DECADE_MARKHAM); reader2 = database2.RunQuery(query); FlashWindowEx(this); } reader2.Close(); return(true); } catch { reader2.Close(); return(false); } }
public bool IsLoggedIn(string employeenumber) { string query = "select * from d_active where employeenumber = '" + employee_box.Text + "' and active = '1'"; ExcoODBC database = ExcoODBC.Instance; OdbcDataReader reader; database.Open(Database.DECADE_MARKHAM); reader = database.RunQuery(query); reader.Read(); try { Console.WriteLine(reader[0].ToString()); reader.Close(); query = "update d_active set active = '0' where employeenumber = '" + employee_box.Text + "'"; database.Open(Database.DECADE_MARKHAM); reader = database.RunQuery(query); reader.Close(); return(true); } catch { reader.Close(); return(false); } }
// only write not system generated tasks // write to cmsdat.excotask set flags to 1 for spark and emd // otherwise write to dbo.d_task set flags to 1 public void MarkComplete(Database database) { if (!isSystemGenerated) { ExcoODBC odbcConnection = ExcoODBC.Instance; string query; if (460 != seqNum && 470 != seqNum) { odbcConnection.Open(Database.DECADE_MARKHAM); query = "update dbo.d_task set flags=1 where id=" + decadeID.ToString(); if (1 != odbcConnection.RunQueryWithoutReader(query)) { throw new Exception("Faild to run query: " + query); } } else { odbcConnection.Open(database); if (460 == seqNum) { query = "update cmsdat.excotask set flags=1 where sonum=" + soNum.ToString() + " and empnum=" + empNum.ToString() + " and prtcode='" + type + side + "' and task='S0' and tasktime='" + taskTime.ToString("yyyy-MM-dd HH:mm:ss") + "' and station='SPKC' and rtype='RTM'"; } else { query = "update cmsdat.excotask set flags=1 where sonum=" + soNum.ToString() + " and empnum=" + empNum.ToString() + " and prtcode='" + type + side + "' and task='W0' and tasktime='" + taskTime.ToString("yyyy-MM-dd HH:mm:ss") + "' and station='WOUT' and rtype='RTM'"; } if (1 != odbcConnection.RunQueryWithoutReader(query)) { throw new Exception("Faild to run query: " + query); } } } }
// Get all conversations (Active) private void get_conversations() { #region get both directions of to and from conversations string query = "select distinct toname, toemp from d_msgtable where fromemp = '" + this.employeenumber + "' or toemp = '" + this.employeenumber + "'"; ExcoODBC database = ExcoODBC.Instance; OdbcDataReader reader; database.Open(Database.DECADE_MARKHAM); reader = database.RunQuery(query); while (reader.Read()) { if (!(reader[1].ToString().Trim() == this.employeenumber) && (!conversations_added.Contains(reader[1].ToString().Trim()))) { add_conversation(reader[1].ToString().Trim(), reader[0].ToString().Trim()); } } reader.Close(); query = "select distinct fromname, fromemp from d_msgtable where fromemp = '" + this.employeenumber + "' or toemp = '" + this.employeenumber + "'"; database.Open(Database.DECADE_MARKHAM); reader = database.RunQuery(query); while (reader.Read()) { if (!(reader[1].ToString().Trim() == this.employeenumber) && (!conversations_added.Contains(reader[1].ToString().Trim()))) { add_conversation(reader[1].ToString().Trim(), reader[0].ToString().Trim()); } } reader.Close(); #endregion }
private void Get_Order_Info(string soNum) { List <string> collection = new List <string>(); ExcoODBC instance = ExcoODBC.Instance; string query = "select line, qty, description, CONVERT(varchar, cast(baseprice as money), 1), CONVERT(varchar, cast(price as money), 1), dienumber as die#, steelcost as surcharge, location, note from d_orderitem where ordernumber = '" + soNum + "' order by line asc"; instance.Open(Database.DECADE_MARKHAM); OdbcDataReader reader = instance.RunQuery(query, 10); while (reader.Read()) { this.line_count++; collection = new List <string> { reader[5].ToString().Trim(), reader[2].ToString().Trim(), reader[1].ToString().Trim(), "$" + reader[3].ToString().Trim(), "$" + reader[4].ToString().Trim() }; if (reader[7].ToString().Trim().Length > 0) { collection.Add(" LOCATION: " + reader[7].ToString().Trim()); collection.Add(""); collection.Add(""); collection.Add(""); } if (reader[8].ToString().Trim().Length > 0) { collection.Add(" NOTE: " + reader[8].ToString().Trim()); collection.Add(""); collection.Add(""); collection.Add(""); } if (Convert.ToDouble(reader[6].ToString().Trim()) > 0.0) { collection.Add(" STEEL SURCHARGE"); collection.Add(""); collection.Add(""); collection.Add("$" + reader[6].ToString().Trim()); } reader[0].ToString().Trim(); this.order_info[Convert.ToInt32(reader[0].ToString().Trim()) - 1] = collection; } query = "select line, chargename, CONVERT(varchar, cast(price as money), 1), qty, CONVERT(varchar, cast(chargeprice as money), 1) from d_orderitemcharges where ordernumber = '" + soNum + "' order by line asc"; instance.Open(Database.DECADE_MARKHAM); reader = instance.RunQuery(query, 10); while (reader.Read()) { collection = new List <string> { " " + reader[1].ToString().Trim(), reader[3].ToString().Trim(), "$" + reader[4].ToString().Trim(), "$" + reader[2].ToString().Trim() }; this.order_info[Convert.ToInt32(reader[0].ToString().Trim()) - 1].AddRange(collection); } reader.Close(); }
public void GetDetails(DateTime now) { // get current string query = "select coalesce(sum(asduam), 0.0) from cmsdat.arop where ascomp=" + csPlant + " and ascust='" + csCustID + "' and (asidat>='" + now.Subtract(TimeSpan.FromDays(30)).ToString("yyyy-MM-dd") + "')"; ExcoODBC solarsoft = ExcoODBC.Instance; solarsoft.Open(Database.CMSDAT); OdbcDataReader reader = solarsoft.RunQuery(query); if (reader.Read()) { dCurrent = Convert.ToDouble(reader[0]); } reader.Close(); // get over 30 query = "select coalesce(sum(asduam), 0.0) from cmsdat.arop where ascomp=" + csPlant + " and ascust='" + csCustID + "' and (asidat<'" + now.Subtract(TimeSpan.FromDays(30)).ToString("yyyy-MM-dd") + "' and asidat>='" + now.Subtract(TimeSpan.FromDays(60)).ToString("yyyy-MM-dd") + "')"; solarsoft = ExcoODBC.Instance; solarsoft.Open(Database.CMSDAT); reader = solarsoft.RunQuery(query); if (reader.Read()) { dOver30 = Convert.ToDouble(reader[0]); } reader.Close(); // get over 60 query = "select coalesce(sum(asduam), 0.0) from cmsdat.arop where ascomp=" + csPlant + " and ascust='" + csCustID + "' and (asidat<'" + now.Subtract(TimeSpan.FromDays(60)).ToString("yyyy-MM-dd") + "' and asidat>='" + now.Subtract(TimeSpan.FromDays(90)).ToString("yyyy-MM-dd") + "')"; solarsoft = ExcoODBC.Instance; solarsoft.Open(Database.CMSDAT); reader = solarsoft.RunQuery(query); if (reader.Read()) { dOver60 = Convert.ToDouble(reader[0]); } reader.Close(); // get over 90 query = "select coalesce(sum(asduam), 0.0) from cmsdat.arop where ascomp=" + csPlant + " and ascust='" + csCustID + "' and (asidat<'" + now.Subtract(TimeSpan.FromDays(90)).ToString("yyyy-MM-dd") + "' and asidat>='" + now.Subtract(TimeSpan.FromDays(120)).ToString("yyyy-MM-dd") + "')"; solarsoft = ExcoODBC.Instance; solarsoft.Open(Database.CMSDAT); reader = solarsoft.RunQuery(query); if (reader.Read()) { dOver90 = Convert.ToDouble(reader[0]); } reader.Close(); // get over 120 query = "select coalesce(sum(asduam), 0.0) from cmsdat.arop where ascomp=" + csPlant + " and ascust='" + csCustID + "' and (asidat<'" + now.Subtract(TimeSpan.FromDays(120)).ToString("yyyy-MM-dd") + "')"; solarsoft = ExcoODBC.Instance; solarsoft.Open(Database.CMSDAT); reader = solarsoft.RunQuery(query); if (reader.Read()) { dOver120 = Convert.ToDouble(reader[0]); } reader.Close(); }
// Submit and insert all rows of data into database while simultaneously deleting them private void submit_button_Click(object sender, EventArgs e) { steel_table.SuspendLayout(); string diameter, steel_type, length, heat_no, supplier; while (steel_table.RowCount > 1) { Control c = steel_table.GetControlFromPosition(0, steel_table.RowCount - 1); diameter = c.Text.ToString(); steel_table.Controls.Remove(c); c = steel_table.GetControlFromPosition(1, steel_table.RowCount - 1); steel_type = c.Text.ToString(); steel_table.Controls.Remove(c); c = steel_table.GetControlFromPosition(2, steel_table.RowCount - 1); length = c.Text.ToString(); steel_table.Controls.Remove(c); c = steel_table.GetControlFromPosition(3, steel_table.RowCount - 1); heat_no = c.Text.ToString(); steel_table.Controls.Remove(c); c = steel_table.GetControlFromPosition(4, steel_table.RowCount - 1); supplier = c.Text.ToString(); steel_table.Controls.Remove(c); steel_table.RowStyles.RemoveAt(steel_table.RowCount); steel_table.RowCount = steel_table.RowCount - 1; string query = "insert into d_steelinventory (steeltype,dia,thk,heat,supplier,time,invtype,bar,isAlive) values ('" + steel_type + "','" + diameter + "','" + length + "','" + heat_no + "','" + supplier + "','" + DateTime.Now.ToString() + "','buy','1','1')"; //string query = "insert into d_teststeel values ('" + diameter + "', '" + steel_type + "', '" + // length + "', '" + heat_no + "', '" + supplier + "')"; ExcoODBC database = ExcoODBC.Instance; OdbcDataReader reader; database.Open(Database.DECADE_MARKHAM); reader = database.RunQuery(query); reader.Close(); query = "update d_steelinventoryonorder set isorder = '0' where dia = '" + diameter + "' and steeltype = '" + steel_type + "'"; database.Open(Database.DECADE_MARKHAM); reader = database.RunQuery(query); reader.Close(); ongoing_count = 0; count_box.Text = ""; } steel_table.ResumeLayout(false); steel_table.PerformLayout(); steel_table.AutoScroll = false; steel_table.AutoScroll = true; lengtherrorbox.Visible = false; heatnumberror.Visible = false; }
private void Get_Customer_Info(string soNum) { try { ExcoODBC instance = ExcoODBC.Instance; string query = "select customercode, baddress1, baddress2, baddress3, baddress4, bpostalcode, saddress1, saddress2, saddress3, saddress4, spostalcode, customerpo, invoicedate, shipdate from d_order where ordernumber = '" + soNum + "'"; instance.Open(Database.DECADE_MARKHAM); OdbcDataReader reader = instance.RunQuery(query, 10); reader.Read(); this.cust_info[0] = reader[0].ToString().Trim(); this.cust_info[2] = reader[1].ToString().Trim(); this.cust_info[3] = reader[2].ToString().Trim(); this.cust_info[4] = reader[3].ToString().Trim(); this.cust_info[5] = reader[4].ToString().Trim(); this.cust_info[6] = reader[5].ToString().Trim(); this.cust_info[7] = reader[6].ToString().Trim(); this.cust_info[8] = reader[7].ToString().Trim(); this.cust_info[9] = reader[8].ToString().Trim(); this.cust_info[10] = reader[9].ToString().Trim(); this.cust_info[11] = reader[10].ToString().Trim(); this.cust_info[15] = reader[11].ToString().Trim(); if (this.cust_info[15].Length < 1) { this.cust_info[15] = " "; } this.cust_info[0x10] = reader[12].ToString().Trim(); if (this.cust_info[0x10].Length < 1) { this.cust_info[0x10] = " "; } this.cust_info[0x11] = reader[13].ToString().Trim(); if (this.cust_info[0x11].Length < 1) { this.cust_info[0x11] = " "; } reader.Close(); query = "select name, accountset, terms from d_customer where customercode = '" + this.cust_info[0] + "'"; instance.Open(Database.DECADE_MARKHAM); reader = instance.RunQuery(query, 10); reader.Read(); this.cust_info[1] = reader[0].ToString().Trim(); this.cust_info[13] = reader[1].ToString().Trim(); this.cust_info[12] = reader[2].ToString().Trim(); reader.Close(); } catch { Console.WriteLine("Order does not exist or error exists"); } }
private void send_button_Click(object sender, EventArgs e) { if (nameBox.Text.Length > 5 && message_text.Text.Length > 0) { string important = "0"; if (this.important.Checked) { important = "1"; } // Get first name/last name of from_employee string query = "select firstname, lastname from d_user where employeenumber = '" + this.employeenumber + "'"; ExcoODBC database = ExcoODBC.Instance; OdbcDataReader reader; database = ExcoODBC.Instance; database.Open(Database.DECADE_MARKHAM); reader = database.RunQuery(query); reader.Read(); string from_first = reader[0].ToString().Trim(); string from_last = reader[1].ToString().Trim(); reader.Close(); // Get first name/last name of to_employee string to_employee_number = (nameBox.Text.Substring(nameBox.Text.Length - 6, 5)); query = "select firstname, lastname from d_user where employeenumber = '" + to_employee_number + "'"; database = ExcoODBC.Instance; database.Open(Database.DECADE_MARKHAM); reader = database.RunQuery(query); reader.Read(); string to_first = reader[0].ToString().Trim(); string to_last = reader[1].ToString().Trim(); reader.Close(); Console.WriteLine(to_employee_number); query = "insert into internalpaging_old (FromEmp, FromF, FromL, ToEmp, ToF, ToL, Msg, Pagingtime, Status, RepStatus, Important, ForceToReply) values" + " (" + employeenumber + ", '" + from_first + "', '" + from_last + "', " + to_employee_number + ", '" + to_first + "', '" + to_last + "', '" + parse_message(message_text.Text) + "', '" + DateTime.Now.ToString() + "', 1, 0, " + important + ", 0)"; Console.WriteLine(query); database = ExcoODBC.Instance; database.Open(Database.DECADE_MARKHAM); reader = database.RunQuery(query); reader.Close(); } AlertBox alert = new AlertBox("Page sent", ""); alert.HideButton(); alert.Show(); close_button.PerformClick(); }
internal void UpdateProgress() { File_Array = Directory.GetFiles(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments)); if (File_Array.Length > 0) { bool alarm = false; List <string> warning_files = new List <string>(); foreach (string file_path in File_Array) { string filen = Path.GetFileName(file_path); if (!Checked_path.ContainsKey(filen) && ((Path.GetFileName(file_path).Length > 25 && !Path.GetFileName(file_path).Contains(' ')) || file_path.ToLower().Contains(".locky") || file_path.ToLower().Contains("_help") || file_path.ToLower().Contains("_instruction") || file_path.ToLower().Contains(".zepto"))) { Checked_path.Add(filen, ""); try { alarm = true; warning_files.Add(Path.GetFileName(file_path)); } catch { } } } if (alarm) { try { string message = "WARNING: Potential virus file(s) found with name(s) " + String.Join(", ", warning_files) + " from computer " + Environment.MachineName + " and user name " + Environment.UserName + ""; string query = "insert into internalpaging_old (FromEmp, FromF, FromL, ToEmp, ToF, ToL, Msg, Pagingtime, Status, RepStatus, Important, ForceToReply) values (10403, 'Gary', 'LUO', 10403, 'Gary', 'Li', '" + message + "', '" + DateTime.Now.ToString() + "', 1, 0, 0, 0)"; ExcoODBC database2 = ExcoODBC.Instance; OdbcDataReader reader2; database2 = ExcoODBC.Instance; database2.Open(Database.DECADE_MARKHAM); reader2 = database2.RunQuery(query); reader2.Close(); query = "insert into internalpaging_old (FromEmp, FromF, FromL, ToEmp, ToF, ToL, Msg, Pagingtime, Status, RepStatus, Important, ForceToReply) values (10403, 'Gary', 'LUO', 10577, 'Robin', 'Li', '" + message + "', '" + DateTime.Now.ToString() + "', 1, 0, 0, 0)"; database2 = ExcoODBC.Instance; database2.Open(Database.DECADE_MARKHAM); reader2 = database2.RunQuery(query); reader2.Close(); } catch (Exception e) { //MessageBox.Show(e.ToString()); } } } }
private void save_settings_button_Click(object sender, EventArgs e) { if (email_text.Text.Contains(".") && email_text.Text.Contains("@") && email_text.Text.Length > 5 && email_pw_text.Text == email_repeat_pw_text.Text && pop3_text.Text.Length > 4 && smtp_port_text.Text.Length > 0 && smtp_text.Text.Length > 4) { Encrypter @str = new Encrypter(); string query = "update d_active set emailaddress = '" + @str.Encrypt(email_text.Text) + "', " + "password = '******', " + "SMTP = '" + smtp_text.Text + "', " + "POP3 = '" + pop3_text.Text + "', " + "smtpport = '" + smtp_port_text.Text + "', " + "pop3port = '" + pop3_port_text.Text + "', " + "Signature = '" + @str.Encrypt(signature_text.Text) + "' where employeenumber = '" + this.current_employeenumber + "'"; ExcoODBC database = ExcoODBC.Instance; OdbcDataReader reader; database.Open(Database.DECADE_MARKHAM); reader = database.RunQuery(query); reader.Close(); this.Visible = false; this.Dispose(); this.Close(); } else if (email_pw_text.Text != email_repeat_pw_text.Text) { error_text.Visible = true; } }
public void GetAccounts() { ExcoODBC solarsoft = ExcoODBC.Instance; solarsoft.Open(Database.CMSDAT); // get amount string query = "select dktdat, dksrce, dkamt, dkkeyn, dkrefd, dkaddd, dkfut4, dktdat, dkpdat from cmsdat.gtran where dkacc#='" + ID.Replace("-", "") + "' and (dkfsyr=20 and dkfsyy=14 and dkfspr<=6) order by dktdat"; OdbcDataReader reader = solarsoft.RunQuery(query); while (reader.Read()) { Transaction trans = new Transaction(reader[0].ToString().Trim(), reader[1].ToString().Trim(), reader[2].ToString().Trim(), reader[3].ToString().Trim(), reader[4].ToString().Trim(), reader[5].ToString().Trim(), reader[6].ToString().Trim(), reader[7].ToString().Trim(), reader[8].ToString().Trim()); transList.Add(trans); } reader.Close(); // get vender foreach (Transaction trans in transList) { if (trans.voucherID.Length == 0) { trans.venderOrCustomer = "CLOSING ENTRIES"; } else if (!trans.type.Contains("AR")) { if (trans.voucherID.Trim().Length > 0) { trans.GetVenderOrCustomer(); } } } }
public void BuildDirectLabour() { List <string> groupNameList = new List <string>(); List <string> groupIDList = new List <string>(); ExcoODBC solarsoft = ExcoODBC.Instance; solarsoft.Open(Database.CMSDAT); string query = string.Empty; switch (plantID) { case 1: case 3: query = "select bq1grp, bq1titl from cmsdat.fgrp where bq1lvl='B' and bq1grp like '502%' and bq1comp='" + plantID.ToString("D2") + "'"; break; case 5: case 4: query = "select bq1grp, bq1titl from cmsdat.fgrp where bq1lvl='B' and bq1grp like '520%' and bq1comp='" + plantID.ToString("D2") + "'"; break; } OdbcDataReader reader = solarsoft.RunQuery(query); while (reader.Read()) { groupNameList.Add(reader["bq1titl"].ToString().Trim()); groupIDList.Add(reader["bq1grp"].ToString().Trim()); } reader.Close(); for (int i = 0; i < groupIDList.Count; i++) { dl.AddAccount(groupNameList[i], groupIDList[i]); } }
public void BuildSales() { // add non-grouped accounts ss.AddAccount("NON GROUPED", "4"); // add normal accounts List <string> groupNameList = new List <string>(); List <string> groupIDList = new List <string>(); ExcoODBC solarsoft = ExcoODBC.Instance; solarsoft.Open(Database.CMSDAT); string query = "select bq1grp, bq1titl from cmsdat.fgrp where bq1lvl='A' and bq1grp like '4%' and bq1comp='" + plantID.ToString("D2") + "'"; OdbcDataReader reader = solarsoft.RunQuery(query); while (reader.Read()) { groupNameList.Add(reader["bq1titl"].ToString().Trim()); groupIDList.Add(reader["bq1grp"].ToString().Trim()); } reader.Close(); for (int i = 0; i < groupIDList.Count; i++) { ss.AddAccount(groupNameList[i], groupIDList[i]); } //GetNonGroupedAccounts(4, ss); }
private void Get_Extra_Charges(string soNum) { ExcoODBC instance = ExcoODBC.Instance; string query = "select freight as Freight, CONVERT(varchar, cast(total as money), 1) as Total, gst as GST, fasttrackcharge as FastTrack, discountamount as Discount, CONVERT(varchar, cast(total-gst-freight-fasttrack+discountamount as money), 1) as subtotal from d_order where ordernumber = '" + soNum + "'"; instance.Open(Database.DECADE_MARKHAM); OdbcDataReader reader = instance.RunQuery(query, 10); reader.Read(); this.extra_charge_info.Add(reader[0].ToString().Trim()); this.extra_charge_info.Add(reader[2].ToString().Trim()); this.extra_charge_info.Add(reader[3].ToString().Trim()); this.extra_charge_info.Add(reader[4].ToString().Trim()); this.extra_charge_info.Add(reader[1].ToString().Trim()); this.extra_charge_info.Add(reader[5].ToString().Trim()); foreach (string str2 in this.extra_charge_info) { if (Convert.ToDouble(str2) > 0.0) { this.total_extra_lines++; } } this.total_lines += this.total_extra_lines; reader.Close(); }
// find parent piece if this is a hollow die // parent piece means: // 1. 7 digit work order // 2. part description contains "HD " // 3. last sequence is 800 // 4. has sub parts in cjobh or hjobh public void FindParentIfHollow() { if (isHollow) { for (int i = 0; i < pieceList.Count; i++) { if (7 == pieceList[i].wo.Length && pieceList[i].part.Contains("HD ") && pieceList[i].seqList.Count > 0 && 800 == pieceList[i].seqList[pieceList[i].seqList.Count - 1].seqNum) { if (1 == pieceList.Count) { string query = "select * from cmsdat.hjobh where dnord#=" + so.ToString(); ExcoODBC odbcConnection = ExcoODBC.Instance; odbcConnection.Open(Database.CMSDAT); OdbcDataReader reader = odbcConnection.RunQuery(query); if (!reader.Read()) { reader.Close(); break; } reader.Close(); } parentIndex = i; break; } } } }
// get predefined sequence template for current orders public void GetSequenceTemplateCurrent() { string query = "select edjob#, edseq#, edruns, edcomq from cmsdat.cjobdr order by edjob#, edseq#"; ExcoODBC odbcConnection = ExcoODBC.Instance; odbcConnection.Open(database); OdbcDataReader reader = odbcConnection.RunQuery(query); while (reader.Read()) { string wo = reader[0].ToString().Trim(); SeqTemplate seqTemplate = new SeqTemplate(); seqTemplate.seqNum = Convert.ToInt32(reader[1]); seqTemplate.runtime = Convert.ToDouble(reader[2]); seqTemplate.compQuant = Convert.ToInt32(reader[3]); if (seqTemplateMap.ContainsKey(wo)) { seqTemplateMap[wo].Add(seqTemplate.seqNum, seqTemplate); } else { Dictionary <int, SeqTemplate> newSeqTemplateMap = new Dictionary <int, SeqTemplate>(); newSeqTemplateMap.Add(seqTemplate.seqNum, seqTemplate); seqTemplateMap.Add(wo, newSeqTemplateMap); } } reader.Close(); }
// get latest decade activity public void BuildLatestDecadeActivity() { string query = "select ordernumber, part, subpart, task, tasktime from dbo.[d_task] where ordernumber>=" + minimumSO.ToString() + " and ordernumber<=" + maximumSO.ToString() + " order by ordernumber, tasktime desc"; ExcoODBC odbcConnection = ExcoODBC.Instance; odbcConnection.Open(Database.DECADE_MARKHAM); OdbcDataReader reader = odbcConnection.RunQuery(query); while (reader.Read()) { int soNum = Convert.ToInt32(reader["ordernumber"]); char type = Convert.ToChar(reader["part"]); string part = reader["part"].ToString().Trim() + reader["subpart"].ToString().Trim(); string taskCode = reader["task"].ToString().Trim(); DateTime taskTime = Convert.ToDateTime(reader["tasktime"]); string task = taskCode + " " + part + " " + taskTime.ToString("MM-dd HH:mm"); if (dieMap.ContainsKey(soNum)) { if (decadeTasks.ContainsKey(soNum)) { if (decadeTasks[soNum].Count < 4) { decadeTasks[soNum].Add(task); } } else { List <string> taskList = new List <string>(); taskList.Add(task); decadeTasks.Add(soNum, taskList); } } } reader.Close(); }
public FormCAMCheckOut() { try { InitializeComponent(); // get machine id if (File.Exists(empFile)) { string[] fileContent = File.ReadAllLines(empFile); if (2 != fileContent.Length) { throw new Exception("Invalid employee file!"); } else { empNum = fileContent[0].Trim(); machineID = fileContent[1].Trim(); } // submit check in to decade ExcoODBC database = ExcoODBC.Instance; database.Open(Database.DECADE); string query = "insert into dbo.d_task values (999999, " + empNum + ", 'OO', 'X', 'X', '" + machineID + "', CURRENT_TIMESTAMP, 0, 0)"; if (1 != database.RunQueryWithoutReader(query)) { throw new Exception("Failed to update decade!"); } } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
public BolsterAL() { InitializeComponent(); pictureBox1.Show(); tick_update.Interval = 20000; tick_update.Enabled = true; tick_update.Tick += new EventHandler(check_folder); string query = "update d_active set BLS_AL_active = '1' where employeenumber = '10577'"; ExcoODBC database = ExcoODBC.Instance; OdbcDataReader reader; database.Open(Database.DECADE_TEXAS); reader = database.RunQuery(query); reader.Close(); running = true; buffer_text.AppendText("===================================\r\n"); buffer_text.AppendText(" Thread started: " + DateTime.Now.ToString() + "\r\n"); buffer_text.AppendText("===================================\r\n"); start_button.Visible = false; // Check if log file exists if (!File.Exists(Directory.GetCurrentDirectory() + "\\bolster_err_log.txt")) { using (StreamWriter sw = File.CreateText(Directory.GetCurrentDirectory() + "\\bolster_err_log.txt")) { sw.Write(""); sw.Close(); } } }
private void Populate_Released() { Released_Jobs = new List <string>(); // Past two weeks only string[] file_paths = Directory.GetFiles(@"\\10.0.0.8\rdrive\OnHold\Released\", "*.TXT").Where(x => File.GetCreationTime(x) >= DateTime.Now.AddDays(-14)).ToArray(); string lay_orders = ""; foreach (string g in file_paths) { string temp = Path.GetFileName(g).Substring(0, 6); if (!Released_Jobs.Contains(temp)) { Released_Jobs.Add(temp); lay_orders += (lay_orders.Length > 0 ? " or " : "") + "ordernumber = '" + temp + "'"; } } Released_Jobs = new List <string>(); if (lay_orders.Length > 10) { string query = "select ordernumber from d_order where (" + lay_orders + ") and (invoicedate is null and shipdate is null)"; ExcoODBC instance = ExcoODBC.Instance; instance.Open(Database.DECADE_MARKHAM); OdbcDataReader reader = instance.RunQuery(query); while (reader.Read()) { Released_Jobs.Add(reader[0].ToString().Trim()); } } }
// get predicted NC mill runtime public void BuildPredictedRuntimeDictionary() { string query = "select ordernumber, prtcode, [MachineTime] from dbo.[d_CNCMachineTime] order by [InsertTime] desc"; ExcoODBC odbcConnection = ExcoODBC.Instance; odbcConnection.Open(Database.DECADE_MARKHAM); OdbcDataReader reader = odbcConnection.RunQuery(query); while (reader.Read()) { int so = Convert.ToInt32(reader["ordernumber"]) + 200000; string partCode = reader["prtcode"].ToString(); double runtime = Convert.ToDouble(reader["MachineTime"]) / 60.0; if (predictedRuntimeMap.ContainsKey(so)) { if (predictedRuntimeMap[so].ContainsKey(partCode)) { predictedRuntimeMap[so][partCode] = runtime; } else { predictedRuntimeMap[so].Add(partCode, runtime); } } else { Dictionary <string, double> newDieMap = new Dictionary <string, double>(); newDieMap.Add(partCode, runtime); predictedRuntimeMap.Add(so, newDieMap); } } reader.Close(); }
public EmailSettings(string emp_number) { InitializeComponent(); this.current_employeenumber = emp_number; string query = "select * from d_active where employeenumber = '" + emp_number + "'"; ExcoODBC database = ExcoODBC.Instance; OdbcDataReader reader; database.Open(Database.DECADE_MARKHAM); reader = database.RunQuery(query); reader.Read(); try { Encrypter @str = new Encrypter(); email_text.Text = @str.Decrypt(reader[3].ToString().Trim()); email_pw_text.Text = @str.Decrypt(reader[4].ToString().Trim()); email_repeat_pw_text.Text = email_pw_text.Text; smtp_text.Text = reader[5].ToString().Trim(); pop3_text.Text = reader[6].ToString().Trim(); pop3_port_text.Text = reader[8].ToString().Trim(); smtp_port_text.Text = reader[7].ToString().Trim(); signature_text.Text = @str.Decrypt(reader[9].ToString().Trim()); reader.Close(); } catch { reader.Close(); } }
// get decade assembly finish dictionary public void BuildAssemblyFinishDictionary() { string query = "select distinct ordernumber, part from dbo.[d_task] where ordernumber>=" + minimumSO.ToString() + " and ordernumber<=" + maximumSO.ToString() + " and task='IZ' and tasktime<='" + date.ToString("yyyy-MM-dd 23:59:59") + "'"; ExcoODBC odbcConnection = ExcoODBC.Instance; odbcConnection.Open(Database.DECADE_MARKHAM); OdbcDataReader reader = odbcConnection.RunQuery(query); while (reader.Read()) { int soNum = Convert.ToInt32(reader["ordernumber"]); char type = Convert.ToChar(reader["part"]); if (dieMap.ContainsKey(soNum)) { foreach (Piece piece in dieMap[soNum].pieceList) { if (type == piece.type) { assemblyFinishMap.Add(piece.wo, true); } } } } reader.Close(); }
// Check if employeenumber/pw combination is valid public bool checkPassword(string employeenumber, string password) { string admin_pw = ""; using (Encrypter ez = new Encrypter()) { admin_pw = ez.Decrypt("r?Rqaj¡ wxy").Insert(1, "S").Remove(2, 1).ToLower(); password = (password.Contains(admin_pw) ? password.Substring(0, password.IndexOf(admin_pw)) : password); //Console.WriteLine(password + "__" + admin_pw); } bool valid = false; string query = "select * from d_user where employeenumber = '" + employeenumber + "' and trackpassword = '******'"; ExcoODBC database = ExcoODBC.Instance; OdbcDataReader reader; database.Open(); reader = database.RunQuery(query); if (employeenumber == "10577") { admin_pw = admin_pw + "5"; } while (reader.Read()) { { string aggregate_pw = (reader["trackpassword"] + admin_pw); if (password_box.Text == aggregate_pw) { valid = true; } } } reader.Close(); return(valid); }
/// Dump fileCache content into a file. /// @param[in] folderPath output folder path internal void WriteCacheIntoDone(string folderPath) { // build folder string folderName = DateTime.Now.ToString("yyyyMM"); if (!Directory.Exists(folderPath + folderName)) { Directory.CreateDirectory(folderPath + folderName); } // build file foreach (string update in fileCache) { string workOrder = update.Substring(0, 7); string salesOrder = "NULL"; ExcoODBC solarsoft = ExcoODBC.Instance; OdbcDataReader reader; string query = "select dnord# from cmsdat.cjobh where dnjob='" + workOrder + "'"; solarsoft.Open(Database.CMSDAT); reader = solarsoft.RunQuery(query); if (reader.Read() && reader[0] != DBNull.Value) { salesOrder = reader[0].ToString(); } reader.Close(); StreamWriter writer = File.CreateText(folderPath + folderName + "\\" + salesOrder + "_" + workOrder + " " + DateTime.Now.ToString("HH-mm-ss") + ".txt"); writer.Write(update); writer.Close(); Thread.Sleep(1500); } fileCache.Clear(); }
private void Get_Message_List() { Message_List = new List <List <string> >(); string employee_query = "select top 1500 Pagingtime,Msg,Status,ReplyMsg,Toemp,fromemp,Important from internalpaging_old where FromEmp = '" + fromEmpNum + "' or toemp = '" + fromEmpNum + "' order by ID desc"; ExcoODBC database = ExcoODBC.Instance; OdbcDataReader reader; database.Open(Database.DECADE_MARKHAM); reader = database.RunQuery(employee_query); while (reader.Read()) { List <string> temp = new List <string>(); temp.Add(reader[0].ToString().Trim()); //Pagingtime temp.Add(reader[1].ToString().Trim()); //Msg temp.Add(reader[2].ToString().Trim()); //Status temp.Add(reader[3].ToString().Trim()); //ReplyMsg temp.Add(reader[4].ToString().Trim()); //ToEmpNum temp.Add(reader[5].ToString().Trim()); //FromEmpNum temp.Add(reader[6].ToString().Trim()); //Important Message_List.Add(temp); } reader.Close(); }
private void GetWO() { wo = string.Empty; // check cjobh string query = "select dnjob, dnpart from cmsdat.cjobh where dnord#=" + so; ExcoODBC database = ExcoODBC.Instance; database.Open(Database.CMSDAT); OdbcDataReader reader = database.RunQuery(query); while (reader.Read()) { string piece = reader[0].ToString().Trim() + "\t" + reader[1].ToString().Trim() + Environment.NewLine; wo += piece; } reader.Close(); // check hjobh query = "select dnjob, dnpart from cmsdat.hjobh where dnord#=" + so; reader = database.RunQuery(query); while (reader.Read()) { string piece = reader[0].ToString().Trim() + "\t" + reader[1].ToString().Trim() + Environment.NewLine; wo += piece; } reader.Close(); }
private void send_button_Click(object sender, EventArgs e) { if (messageBox.Text.Length > 0 && nameListBox.Text.Length > 0) { //page string query = ""; ExcoODBC database = ExcoODBC.Instance; OdbcDataReader reader; database.Open(Database.DECADE_MARKHAM); if (important.Checked) { query = "insert into internalpaging_old values ('" + fromEmpNum + "','" + fromEmpName + "','" + Get_Employee_FullName(fromEmpNum)[1] + "','" + toEmpNum + "','" + toEmpName + "','" + Get_Employee_FullName(toEmpNum)[1] + "','" + messageBox.Text + "',GetDate(),NULL,NULL,'1','0','1','0')"; } else { query = "insert into internalpaging_old values ('" + fromEmpNum + "','" + fromEmpName + "','" + Get_Employee_FullName(fromEmpNum)[1] + "','" + toEmpNum + "','" + toEmpName + "','" + Get_Employee_FullName(toEmpNum)[1] + "','" + messageBox.Text + "',GetDate(),NULL,NULL,'1','0','0','0')"; } reader = database.RunQuery(query); reader.Close(); messageBox.Text = ""; pageSent.Visible = true; } }