private void Get_Customers() { ExcoODBC instance = ExcoODBC.Instance; #region Get All Customers Customer_List = new List <Customer>(); string query = "select customercode, name, pricelist from d_customer"; instance.Open(masterDB); OdbcDataReader reader = instance.RunQuery(query); while (reader.Read()) { Customer c = new Customer(); c.custCode = reader[0].ToString().Trim(); c.Name = reader[1].ToString().Trim(); c.PLCode = reader[2].ToString().Trim(); Customer_List.Add(c); } reader.Close(); #endregion // Select database using (var DBS = new DatabaseSelector(parent, Customer_List, "Select Customer", this.Location, this.Size, false)) { var returnv = DBS.ShowDialog(); // If database valid if (returnv == DialogResult.OK && DBS.dbName.Length > 0) { Ref_CustCode = DBS.dbName.Substring(DBS.dbName.Length - 7, 6);// Force form to redraw } } }
private void button4_Click(object sender, EventArgs e) { Grey_Out(); ExcoODBC instance = ExcoODBC.Instance; #region Get All Customers Customer_List = new List <Customer>(); string query = "select customercode, name, pricelist from d_customer"; instance.Open(masterDB); OdbcDataReader reader = instance.RunQuery(query); while (reader.Read()) { Customer c = new Customer(); c.custCode = reader[0].ToString().Trim(); c.Name = reader[1].ToString().Trim(); c.PLCode = reader[2].ToString().Trim(); Customer_List.Add(c); } reader.Close(); #endregion string custName = ""; // Select database using (var DBS = new DatabaseSelector(parent, Customer_List, "Select Customer", this.Location, this.Size, false, "SAVE")) { var returnv = DBS.ShowDialog(); // If database valid if (returnv == DialogResult.OK && DBS.dbName.Length > 0) { Ref_CustCode = DBS.dbName.Substring(DBS.dbName.Length - 7, 6); custName = DBS.dbName.Substring(0, (DBS.dbName.Length - 9)).Length > 20 ? DBS.dbName.Substring(0, (DBS.dbName.Length - 9)).Substring(0, 20) : DBS.dbName.Substring(0, (DBS.dbName.Length - 9)); } } #region Background save charges to retain later // create appData directory if (!Directory.Exists(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\ExcoPricingTool")) { Directory.CreateDirectory(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\ExcoPricingTool"); } string rootPath = "EPT-" + Ref_CustCode + "-" + custName + ".ecf"; // Remove illegal path characters string invalid = new string(Path.GetInvalidFileNameChars()) + new string(Path.GetInvalidPathChars()); foreach (char c in invalid) { rootPath = rootPath.Replace(c.ToString(), ""); } string combRootPath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\ExcoPricingTool\\" + rootPath; // Try and delete existing file try { File.Delete(combRootPath); } catch { } List <string> Lines = new List <string>(); //save charges foreach (KeyValuePair <DieType, List <DieCharge> > Die_KVP in parent.Charge_Dictionary) { foreach (DieCharge DC in Die_KVP.Value) { Lines.Add("DC" + "|[D]=" + DC.Dietype + "|[N]=" + DC.Name + "|[F]=" + DC.Formula); } } //File.WriteAllLines(rootPath, Lines); File.WriteAllText(combRootPath, parent.Encrypt_Line(String.Join(Environment.NewLine, Lines))); #endregion Grey_In(); }
private void addSolidButton_Click(object sender, EventArgs e) { Grey_Out(); using (var form = new Yes_No_Dialog(parent, "Are you sure you wish to import ALL associated charges for current part? This might include a lot of miscellaneous part charges. Continue?", "Warning", "No", "Yes", 45, this.Location, this.Size)) { var result = form.ShowDialog(); if (result == DialogResult.OK && form.ReturnValue1 == "1") { // Select database using (var DBS = new DatabaseSelector(parent, null, "Select Database", this.Location, this.Size, true)) { var returnv = DBS.ShowDialog(); // If database valid if (returnv == DialogResult.OK && DBS.dbName.Length > 0) { setDatabase(DBS.dbName);// Force form to redraw #region Get All Customers Customer_List = new List <Customer>(); string query = "select customercode, name, pricelist from d_customer"; instance.Open(masterDB); OdbcDataReader reader = instance.RunQuery(query); while (reader.Read()) { Customer c = new Customer(); c.custCode = reader[0].ToString().Trim(); c.Name = reader[1].ToString().Trim(); c.PLCode = reader[2].ToString().Trim(); Customer_List.Add(c); } reader.Close(); #endregion Application.DoEvents(); // Get customer Get_Customers(); Grey_Out(); if (secondThreadFormHandle == IntPtr.Zero) { Loading_Form form2 = new Loading_Form(parent, this.Location, this.Size, "IMPORTING", "DATABASE") { }; form2.HandleCreated += SecondFormHandleCreated; form2.HandleDestroyed += SecondFormHandleDestroyed; form2.RunInNewThread(false); } // Generate price list Import_Charges(); if (secondThreadFormHandle != IntPtr.Zero) { PostMessage(secondThreadFormHandle, WM_CLOSE, IntPtr.Zero, IntPtr.Zero); } Form_Message_Box FMB = new Form_Message_Box(parent, "Import Successful!", true, -28, this.Location, this.Size); FMB.ShowDialog(); Grey_In(); } } } } Grey_In(); }