public void SaveNewPart(string name, string provider, string description) { this.name = name; string query = $"INSERT INTO `parts_catalog` (`reference`, `name`, `provider`, `description`) VALUES ('{this.reference}', '{this.name}', '{provider}', '{description}')"; InternalApp.ExecuteQuery(query); }
// Check TODO.txt Issue #2 NOT READY YET public void UpdateDeliveryTime() { if (content.Count == 0) { this.deliveryDate = ""; } else { UpdateTotalItems(); string planningQuery = "SELECT * FROM planning"; // Acess planning to compute an estimate delivery time DataTable planningTable = InternalApp.GetDataTable(planningQuery); DataRow firstDateRow = planningTable.Rows[planningTable.Rows.Count - 1]; DateTime firstDateAvailable = Convert.ToDateTime(firstDateRow["date"]); DateTime today = DateTime.Now; int result = DateTime.Compare(firstDateAvailable, today); if (result < 0) { firstDateAvailable = today; } float speed = 9; // TEMPORARY speed fixed at 9 bikes per week float delay = (totalItems / speed) + 3; // Convert delay in days + add 3 days for the delivery DateTime newDeliveryDate = firstDateAvailable.AddDays(Math.Ceiling(delay)); if (newDeliveryDate.DayOfWeek == DayOfWeek.Saturday) { newDeliveryDate = newDeliveryDate.AddDays(2); } if (newDeliveryDate.DayOfWeek == DayOfWeek.Sunday) { newDeliveryDate = newDeliveryDate.AddDays(1); } this.deliveryDate = newDeliveryDate.ToString("yyyy-MM-dd"); } }
public void SaveModel() //needs to be cleaned, create methods in database GetData and SendData { InternalApp.ExecuteQuery($"INSERT into model_catalog(name, price) values('{type}', '{price}');"); foreach (Part part in partList) { InternalApp.ExecuteQuery($"INSERT into model_structure(model_name, reference, quantity) values('{type}','{part.reference}', '{part.quantity}');"); } }
private void AutoPlanner_Btn_Click(object sender, EventArgs e) { Planning.AutoPlanning(8); InternalApp.SetBikeList(); DateTime actualTime = DateTime.Now; UpdateFormDate(actualTime); autoplanner_label.Text = "Successfull"; autoplanner_label.Visible = true; }
public void Build() { DataTable partTable = InternalApp.GetDataTable($"SELECT * FROM model_structure WHERE model_name='{type}'"); foreach (DataRow partRow in partTable.Rows) { Part part = new Part(partRow.Field <string>("reference"), partRow.Field <int>("quantity")); this.AddPart(part); part.Use(); } this.UpdateState("Done"); //Comment for testing }
public Part(string reference, int quantity) { string strQuantity; this.reference = reference; this.quantity = quantity; DataTable nameTable = InternalApp.GetDataTable($"SELECT * FROM parts_catalog WHERE reference='{reference}'"); //Facultatif this.name = nameTable.Rows[0].Field <string>("name"); DataTable partDataTable = InternalApp.GetDataTable($"SELECT * FROM parts_stock WHERE reference='{reference}'"); DataRow partDataRow = partDataTable.Rows[0]; strQuantity = partDataRow["quantity"].ToString(); this.stock = Int32.Parse(strQuantity); }
private void validate_button_Click(object sender, EventArgs e) { InternalApp.bikeList.Clear(); InternalApp.SetBikeList(); //this.Hide(); //var fitterForm = new FitterForm(); stateBike.Clear(); this.Controls.Clear(); InitializeComponent(); FitterFormCharge(); //fitterForm.ShowDialog(); //this.Close(); ShowDayPlanning(fitterPanel); }
private void FitterForm_Load(object sender, EventArgs e) { DateTime date = DateTime.Now; if (date.DayOfWeek == DayOfWeek.Saturday) { date = date.AddDays(2); } if (date.DayOfWeek == DayOfWeek.Sunday) { date = date.AddDays(1); } InternalApp.bikeList.Clear(); InternalApp.SetBikeList(); this.dateOfToday_label.Text = date.ToString("D", CultureInfo.CreateSpecificCulture("en-US")); ShowDayPlanning(fitterPanel); }
private void Confirmbtn_Click(object sender, EventArgs e) { Console.WriteLine("Confirm button pushed"); if (InternalApp.CheckPassword(password_txt.Text)) { Console.WriteLine("Password Confirmed"); this.Hide(); var form = new PartsStock(); form.Location = this.Location; form.StartPosition = FormStartPosition.Manual; form.FormClosing += delegate { this.Close(); }; form.Show(); } else { Text = "Password or username invalid"; MessageBox.Show(Text); } }
private void button4_Click(object sender, EventArgs e) { try { Part part = new Part(clientParams[0], clientParams[1]); if (clientParams[5] == "") { clientParams[5] = "0"; //Abit hardcoded, means that if no data for necessary, default 0 is given. (necessary is bot fixed because no models use that specific part yet) } var form = new OrderPartForm(part, Convert.ToInt32(clientParams[5]) - (Convert.ToInt32(clientParams[3]) + Convert.ToInt32(clientParams[4]))); form.Location = this.Location; form.StartPosition = FormStartPosition.Manual; form.FormClosing += delegate { this.Show(); UpdatePartsTable(); InternalApp.SetRequiredPartsList(); }; form.Show(); } catch { partInfo = "Please select an item"; } }
static void Main() { InternalApp internalApp = new InternalApp(); internalApp.Run(); }
private void Back_Click(object sender, EventArgs e) { InternalApp.bikeList.Clear(); InternalApp.SetBikeList(); this.Close(); }
public void UpdateState(string state) { this.state = state; InternalApp.ExecuteQuery($"UPDATE bike SET cstr_status='{state}' WHERE id='{this.id}'"); }
public void UpdateDate(string date) { InternalApp.ExecuteQuery($"UPDATE planning SET date='{date}' WHERE bike='{this.id}'"); }
public void Use() { stock -= quantity; InternalApp.ExecuteQuery($"UPDATE parts_stock SET quantity={stock} WHERE reference='{reference}'"); }