// создание объектов private static void CreateObjects(IFaker faker) { ClassA a = faker.Create <ClassA>(); objectList.Add(a); ClassB b = faker.Create <ClassB>(); objectList.Add(b); ClassC c = faker.Create <ClassC>(); objectList.Add(c); ClassD d = faker.Create <ClassD>(); objectList.Add(d); ClassE e = faker.Create <ClassE>(); objectList.Add(e); ClassF f = faker.Create <ClassF>(); objectList.Add(f); ClassG g = faker.Create <ClassG>(); objectList.Add(g); ClassH h = faker.Create <ClassH>(); objectList.Add(h); ClassI i = faker.Create <ClassI>(); objectList.Add(i); }
protected override void OnInit(EventArgs e) { base.OnInit(e); srcOptimizeTable.DataFile = GetDirectory() + userDir + MAIN_USER_DATABASE; classE1_1 = new ClassF(GetDirectory() + userDir); classE1_1.Close(); }
public static bool isReCalcNecessary(string username, string path) { Boolean resultMessage; if (isCalculating(path)) { resultMessage = false; } else { ClassF classE1_1 = new ClassF(path); classE1_1.Open(); try { int totalCalc = 0; classE1_1.username = username; classE1_1.SetBasicModelInfo(); classE1_1.calc_return = 0; //0 - none, 1 labor, 2 eq over util, 4 warnings 8 errors ADODB.Recordset recNeedCalc = new ADODB.Recordset(); //check if basecase needs recalc and add to totalCalc DbUse.open_ado_rec(classE1_1.globaldb, ref recNeedCalc, "SELECT * FROM zs0tblWhatIf WHERE zs0tblWhatIf.WID=0;"); int basecaserecalc = Convert.ToInt32(recNeedCalc.Fields["recalc"].Value); if (basecaserecalc != 0) { totalCalc++; } bool recOpened = DbUse.OpenAdoRec(classE1_1.globaldb, recNeedCalc, "SELECT * FROM tblWhatIf WHERE FamilyID = 0 AND recalc = true AND display = -1;"); while (!recNeedCalc.EOF) { totalCalc++; recNeedCalc.MoveNext(); } DbUse.CloseAdoRec(recNeedCalc); if (totalCalc > 0) { resultMessage = true; } else { resultMessage = false; } } catch (Exception) { resultMessage = false; } classE1_1.Close(); } return(resultMessage); }
protected void ReturnToBasecase() { ClassF mpxClass = new ClassF(GetDirectory() + userDir); mpxClass.LoadBaseCase(); //mpxClass.dowhatif_all_end(); // don't know if that's of any use... mpxClass.Close(); Master.PassCurrentWhatifName(""); // hide the current whatif label in master page Master.SetCurrentWhatifLabel(); }
private void bClick_(object sender, RoutedEventArgs e) { Button b = sender as Button; int qty = 0; bool f = int.TryParse(b.Content.ToString().Replace("+", ""), out qty); setQTY(qty); ClassF.wm_sound(@"Data\Beep.wav"); }
protected void btnDefaultRoutingPart_Click(object sneder, EventArgs e) { ClassF classF = new ClassF(GetDirectory() + userDir); try { classF.addfromto_part(int.Parse(dropListProducts.SelectedValue)); tableSync.SyncTablesOnDefaultRouting(int.Parse(dropListProducts.SelectedValue)); } catch (Exception) { } classF.Close(); SetData(); }
protected override void OnInit(EventArgs e) { base.OnInit(e); if (!LocalTablesLinked()) { ResetModelGoToModels(); } try { classE1_1 = new ClassF(GetDirectory() + userDir); classE1_1.Close(); SetWhatifRecordsCommands(); } catch (Exception ex) { logFiles.ErrorLog(ex); } }
public void TestHashSet() { ClassF f = new ClassF { ClassACollection = new HashSet <ClassA> { new ClassA { ValueTypeProp = 123, StringProp = "test" } } }; var f2 = Copier.Copy(f); Assert.NotSame(f.ClassACollection, f2.ClassACollection); Assert.Equal(f.ClassACollection.Select(a => a.StringProp), f2.ClassACollection.Select(a => a.StringProp)); }
protected void btnRoutingShowTimes_Click(object sender, EventArgs e) { btnRoutingShowTimes.Enabled = false; if (btnRoutingShowTimes.Text.Equals("Show Real Percentage")) { gridRouting.Columns[0].Visible = false; this.TABLE_NAME_ROUTING = "tblOpFrTo_d"; btnRoutingShowTimes.Text = "Edit Routings"; { ClassF calc = new ClassF(GetDirectory() + userDir); try { calc = new ClassF(GetDirectory() + userDir); calc.setGlobalVar(); calc.runsqlado("DELETE * FROM tblOpFrTo_d;"); calc.runsqlado("DELETE * FROM zstblerrors;"); calc.inOperRoutingPages = true; calc.MakeActualroute_all(); string errorMsg = calc.GetErrorMessage(); lblErrorRealTimesRouting.Text = "Errors in calculating expressions in routing table:<br/>" + errorMsg; lblErrorRealTimesRouting.Visible = !errorMsg.Trim().Equals(String.Empty); } catch (Exception ex) { logFiles.ErrorLog(ex); Master.ShowErrorMessage("An error has occured while calculating expressions."); } finally { calc.Close(); } } } else { gridRouting.Columns[0].Visible = true; this.TABLE_NAME_ROUTING = "tblOperFrTo"; btnRoutingShowTimes.Text = "Show Real Percentage"; } this.SetData(); btnRoutingShowTimes.Enabled = true; }
//Go to Classes.cs to start this lesson static void Main(string[] args) { //We create instances of a class using the *new* keyword var myInstance = new TestClass(); //When we initialize a class, the properties get the default value for their type. var myClass = new ExampleClass(); Console.WriteLine(myClass.Property1); //Null Console.WriteLine(myClass.Property2); //0 Console.WriteLine(myClass.Property3); //0.0 Console.WriteLine(myClass); //This will output the type. //CONSTRUCTORS var myClassF = new ClassF("stringValue"); var otherClassF = new ClassF("stringValue", 6); //IMPLICIT CONSTRUCTORS var myClassG = new ClassG(); //PUBLIC PARAMETERLESS CONSTRUCTOR var myClassH = new ClassH(); }
public static CalculationResult CalculateResults(ClassF classE1_1) { LogFiles logFiles = new LogFiles(classE1_1.username); if (DbUse.InRunProcess(classE1_1.varlocal, true)) { logFiles.DuplicateRunEndLog(); throw new Exception("Cannot start verification and calculations. The verification and calculations are still in process from the previous run. Please wait."); } DbUse.RunMysql("INSERT INTO usercalc (id) SELECT userlist.id FROM userlist WHERE userlist.sessionid = '" + HttpContext.Current.Session.SessionID + "';"); DbUse.RunMysql("UPDATE usercalc INNER JOIN userlist ON usercalc.id = userlist.id SET total = 1, calc = 1, lastCheck = " + DateTime.Now.Ticks + ", cancel = 0 WHERE userlist.sessionid = '" + HttpContext.Current.Session.SessionID + "';"); DbUse.CreateRunFile(classE1_1.varlocal, classE1_1.username); classE1_1.Open(); classE1_1.SetBasicModelInfo(); // sets glngwid etc. classE1_1.calc_return = 0; //0 - none, 1 labor, 2 eq over util, 4 warnings 8 errors string errorsMessage = ""; string resultsMessage = ""; try { classE1_1.RunDLL(); if (!classE1_1.errorMessageGlobal.Equals("")) { string errorMessageGlobal = classE1_1.errorMessageGlobal; classE1_1.errorMessageGlobal = ""; throw new Exception("The calculations were unsuccessful. " + errorMessageGlobal); } if ((classE1_1.calc_return & CalcClass.ERR_FLAG) > 0) { resultsMessage = do_calc_msg(classE1_1.calc_return, 0); } else { resultsMessage = do_calc_msg(classE1_1.calc_return, 1); } errorsMessage = GetErrorMessage(classE1_1); save_errors_results(classE1_1, resultsMessage, errorsMessage); classE1_1.runsqlado("UPDATE zs0tblWhatif SET display = -1 WHERE WID = " + classE1_1.glngwid + ";"); classE1_1.Close(); } catch (Exception ex) { logFiles.ErrorLog(ex); classE1_1.Close(); DbUse.DeleteRunFile(classE1_1.varlocal, classE1_1.username); logFiles.RunEndLog(); DbUse.RunMysql("DELETE usercalc.* FROM usercalc INNER JOIN userlist ON usercalc.id = userlist.id WHERE userlist.sessionid = '" + HttpContext.Current.Session.SessionID + "';"); throw new Exception("MPX internal error has occured in calculations. Cannot calculate results. " + classE1_1.errorMessageGlobal); } DbUse.DeleteRunFile(classE1_1.varlocal, classE1_1.username); DbUse.RunMysql("DELETE usercalc.* FROM usercalc INNER JOIN userlist ON usercalc.id = userlist.id WHERE userlist.sessionid = '" + HttpContext.Current.Session.SessionID + "';"); logFiles.RunEndLog(); CalculationResult calcResult = new CalculationResult(resultsMessage, errorsMessage); return(calcResult); }
protected bool SaveModel(int saveMode, string name, bool showMessage) { string currDbDir = GetDirectory() + userDir; string modelDir = currDbDir + MODELS + "\\"; string modelName = modelDir + name; string modelInitialName; string originalModel = Master.GetCurrentModel(); if (saveMode == SaveMode.CURRENT_MODEL || saveMode == SaveMode.RENAME_MODEL) { modelInitialName = modelDir + CURRENT_DATABASE; { ClassF classF = new ClassF(GetDirectory() + userDir); classF.Open(); classF.eliminate_nulls0(); classF.check_dock_stock(); //classF.checkDOCKSTOCK(); //classF.clear_all_id_name_flags(); ????? CANNOT FIND classF.set_ids2names(); classF.Close(); } } else if (saveMode == SaveMode.NEW_MODEL) { modelInitialName = modelDir + NEW_MODEL_DATABASE; } string message = "Model '" + name + "'"; try { if (saveMode == SaveMode.NEW_MODEL) { if (!File.Exists(currDbDir + NEW_MODEL_DATABASE)) { File.Copy(GetDirectory() + NEW_MODEL_DATABASE, currDbDir + NEW_MODEL_DATABASE, true); } File.Copy(currDbDir + NEW_MODEL_DATABASE, modelName, true); // save the model message += " was created "; //File.Move(modelInitialName, modelName); } else { if (saveMode == SaveMode.CURRENT_MODEL) { File.Copy(currDbDir + CURRENT_DATABASE, modelName, true); // save the model } else if (saveMode == SaveMode.RENAME_MODEL) { File.Copy(currDbDir + CURRENT_DATABASE, modelName, true); // save the model File.Delete(modelDir + originalModel); // delete the original model } message += " saved successfuly."; } SetModelModified(false); } catch (Exception ex) { logFiles.ErrorLog(ex); if (showMessage) { message += " could not save. "; Master.ShowErrorMessage("An error has occured." + message); } return(false); } CleanUpAfterSave(saveMode, originalModel, name, message, showMessage); return(true); }
public ClassE(ClassF c, ClassF c2) { }
protected void DeleteRow(int rowIndex) { GridViewRow row = grid.Rows[rowIndex]; var newValues = this.GetValues(row); connec = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source= " + GetDirectory() + userDir + MAIN_USER_DATABASE + ";"); OleDbCommand cmd = new OleDbCommand(GetCommandString(Command.DELETE), connec); cmd.Parameters.AddWithValue(FIELDS[0], grid.DataKeys[row.RowIndex][FIELDS[0]]); int key = int.Parse(grid.DataKeys[row.RowIndex][FIELDS[0]].ToString()); try { int prodid = -1; string opname = ""; bool issueRoutingWarning = false; ClassF classA = null; if (TABLE_NAME.Equals("tbloper")) { try { prodid = int.Parse(GetDatabaseField("Prodfore", "OpID", key, "tblOper")); opname = GetDatabaseField("OpNam", "OpID", key, "tblOper"); try { classA = new ClassF(GetDirectory() + userDir); issueRoutingWarning = classA.repair_routings(key, opname, prodid); classA.Close(); } catch (Exception) { } } catch (Exception) { } } connec.Open(); try { int result = cmd.ExecuteNonQuery(); } catch (Exception excep) { Exception excepNew = new Exception("Error in executing delete query. Command string: " + cmd.CommandText + ". Exception message: " + excep.Message, excep); throw excepNew; } connec.Close(); grid.EditIndex = -1; this.SetData(); if (classA == null) { classA = new ClassF(GetDirectory() + userDir); } else { classA.Open(); } if (TABLE_NAME.Equals("tbllabor")) { classA.del_labor_res(key); classA.del_lab_ref(key); } else if (TABLE_NAME.Equals("tblequip")) { classA.del_eq_res(key); classA.del_eq_ref(key); } else if (TABLE_NAME.Equals("tblprodfore")) { classA.del_pt_res(key); } else if (TABLE_NAME.Equals("tbloper")) { // delete oper results ??? ask Greg classA.del_op_res(key); } classA.Close(); if (TABLE_NAME.Equals("tbloper")) { tableSync.UpdateOpNumbers(); } if (issueRoutingWarning) { Master.ShowInfoMessage("Routings for the operation were deleted. Please check out '" + opname + "' routing deleted does not leave a hole in the routings."); } } catch (Exception ex) { logFiles.ErrorLog(ex); try { connec.Close(); connec = null; } catch { } Master.ShowErrorMessage("An error has occured and the record could not get deleted."); } }
private void modeStandart(KeyEventArgs e) { if (e.Key == Key.Enter) { string item = text.Text.TrimEnd().TrimStart().ToUpper(); long digital; bool f = long.TryParse(item, out digital); text.Text = ""; if (f) { XElement elm = find(item); if (elm == null) { var w = new B.messageDlgTime(); w.message.Text = "not found"; w.Show(); _ProductsGrid.Items.Refresh(); } else { int indx = shelfProducts.FindIndex(l => l == elm); string qtys = qty_label.Text.Replace(" box ", "").Replace(" pièces ", "").Replace('_', ' ').Replace('.', ',').Trim(); qty_label.Text = "__"; decimal qty_ = 0.0m; decimal.TryParse(qtys == "0,0" || qtys == string.Empty ? "1,00" : qtys, out qty_); if (indx == -1) { shelfProducts.Insert(0, elm); ClassProducts.updQTYProduct(qty_, elm, tbcb.IsChecked ?? false, typefind); } else { ClassProducts.updQTYProduct(qty_, elm, tbcb.IsChecked ?? false, typefind); shelfProducts.Remove(elm); shelfProducts.Insert(0, elm); } _ProductsGrid.SelectedItem = elm; _ProductsGrid.Items.Refresh(); _ProductsGrid.ScrollIntoView(_ProductsGrid.SelectedItem); ClassF.wm_sound(@"Data\Beep.wav"); // tbcb.IsChecked = true; calcTotal(); } } } }
private void bClick(object sender, RoutedEventArgs e) { ClassF.wm_sound(@"Data\Beep.wav"); setLabelQTY(((Button)sender).Content.ToString()); }
public static string RunAll(string username, string path, string sessionID) { string resultMessage = ""; var resultArray = new List <string[]>(); if (isCalculating(path)) { resultMessage = "Calculations are still in process from the previous run, please wait"; } else { int ret; DbUse.CreateRunFile(path, username); ClassF classE1_1 = new ClassF(path); classE1_1.Open(); try { int totalCalc = 0; int currentCalc = -1; classE1_1.username = username; classE1_1.SetBasicModelInfo(); classE1_1.calc_return = 0; //0 - none, 1 labor, 2 eq over util, 4 warnings 8 errors ADODB.Recordset recNeedCalc = new ADODB.Recordset(); //check if basecase needs recalc and add to totalCalc DbUse.open_ado_rec(classE1_1.globaldb, ref recNeedCalc, "SELECT * FROM zs0tblWhatIf WHERE zs0tblWhatIf.WID=0;"); totalCalc++; bool recOpened = DbUse.OpenAdoRec(classE1_1.globaldb, recNeedCalc, "SELECT * FROM tblWhatIf WHERE FamilyID = 0 AND display = -1;"); //bool recOpened = DbUse.OpenAdoRec(classE1_1.globaldb, recNeedCalc, "SELECT * FROM tblWhatIf;"); while (!recNeedCalc.EOF) { totalCalc++; recNeedCalc.MoveNext(); } DbUse.CloseAdoRec(recNeedCalc); DbUse.RunMysql("INSERT INTO usercalc (id) SELECT userlist.id FROM userlist WHERE userlist.sessionid = '" + sessionID + "';"); DbUse.RunMysql("UPDATE usercalc INNER JOIN userlist ON usercalc.id = userlist.id SET total = " + totalCalc + ", calc = " + currentCalc + ", lastCheck = " + DateTime.Now.Ticks + ", cancel = 0, timePerCalc = 100000000 WHERE userlist.sessionid = '" + sessionID + "';"); classE1_1.global_runalldone = false; classE1_1.global_initwid = classE1_1.glngwid; classE1_1.errorMessageGlobal = ""; while (classE1_1.global_runalldone == false) { classE1_1.calc_return = 0; //classE1_1.Run_All_ReCalc(1); resultArray = classE1_1.CalculateResults(1, sessionID); } if (classE1_1.global_initwid != classE1_1.glngwid) { if (classE1_1.global_initwid != 0) { classE1_1.LoadBaseCase(); ret = classE1_1.LoadWhatIf(classE1_1.global_initwid); } else { classE1_1.LoadBaseCase(); } } ; resultMessage = CalcClass.GetErrorMessage(classE1_1); if (resultMessage.Trim().Equals(String.Empty)) { foreach (var result in resultArray) { if (result[4].Equals("true")) { resultMessage += "<span style='color:#27ae60;'>"; } else { resultMessage += "<span style='color:#c0392b;'>"; } resultMessage += result[0] + ": "; if (!String.IsNullOrEmpty(result[1])) { resultMessage += result[1]; } if (!String.IsNullOrEmpty(result[2])) { resultMessage += result[2]; } if (!String.IsNullOrEmpty(result[3])) { resultMessage += result[3]; } resultMessage += "</span>"; } } //if (resultMessage.Trim().Equals(String.Empty)) //{ // if ((classE1_1.calc_return & CalcClass.ERR_FLAG) > 0) // { // resultMessage = CalcClass.do_calc_msg(classE1_1.calc_return, 0); // } // else // { // resultMessage = CalcClass.do_calc_msg(classE1_1.calc_return, 1); // } //} classE1_1.runsqlado("UPDATE zs0tblWhatif SET display = -1 WHERE WID = " + classE1_1.glngwid + ";"); } catch (Exception) { resultMessage = "MPX internal error has occured"; } classE1_1.Close(); DbUse.RunMysql("DELETE usercalc.* FROM usercalc INNER JOIN userlist ON usercalc.id = userlist.id WHERE userlist.sessionid = '" + sessionID + "';"); DbUse.DeleteRunFile(path, username); } return(resultMessage); }