private void updateControl() { if (dataGridView1.CurrentRow == null) { return; } SupplyAssemblyOrder order = (SupplyAssemblyOrder)dataGridView1.CurrentRow.DataBoundItem; if (order.status == SupplyAssemblyOrderStatus.SENT) { button2.Enabled = true; } else { button2.Enabled = false; } if (order.status == SupplyAssemblyOrderStatus.NEW) { button1.Enabled = true; button3.Enabled = true; button4.Enabled = true; button5.Enabled = true; } else { button1.Enabled = false; button3.Enabled = false; button4.Enabled = false; button5.Enabled = false; } }
private void button2_Click(object sender, EventArgs e) { SupplyAssemblyOrder order = (SupplyAssemblyOrder)dataGridView1.CurrentRow.DataBoundItem; var sscios = from sad in DataService.db.GetTable <SupplyAssemblyDetails>() where sad.supplyAssemblyOrderId == order.id join st in DataService.db.GetTable <SupplierStore>() on sad.supplierStoreId equals st.id select new SupplierStoreComponentInOrder(st.computerComponent.id, st.computerComponent.type, st.computerComponent.name, st.supplierPrice, sad.id, sad.count); foreach (var sscio in sscios) { var ss = DataService.db.GetTable <ShopStore>() .Where(ssP => ssP.computerComponentId == sscio.id) .SingleOrDefault(); if (ss == null) { var shopStore = new ShopStore(sscio.id, sscio.count); DataService.db.GetTable <ShopStore>().InsertOnSubmit(shopStore); } else { ss.count = ss.count + sscio.count; } } order.status = SupplyAssemblyOrderStatus.ARRIVED; DataService.db.SubmitChanges(); updateForm(); }
private void button1_Click(object sender, EventArgs e) { SupplyAssemblyOrder order = (SupplyAssemblyOrder)dataGridView1.CurrentRow.DataBoundItem; order.status = SupplyAssemblyOrderStatus.CANCEL; DataService.db.SubmitChanges(); updateForm(); }
private void button4_Click(object sender, EventArgs e) { SupplyAssemblyOrder order = (SupplyAssemblyOrder)dataGridView1.CurrentRow.DataBoundItem; DataService.db.ExecuteCommand("delete from supply_assembly_details where supply_assembly_order_id = {0}", order.id); DataService.db.SubmitChanges(); updateDataGrid2(); }
private void updateDataGrid2() { SupplyAssemblyOrder order = (SupplyAssemblyOrder)dataGridView1.CurrentRow.DataBoundItem; var sscio = from sad in DataService.db.GetTable <SupplyAssemblyDetails>() where sad.supplyAssemblyOrderId == order.id join st in DataService.db.GetTable <SupplierStore>() on sad.supplierStoreId equals st.id select new SupplierStoreComponentInOrder(st.computerComponent.id, st.computerComponent.type, st.computerComponent.name, st.supplierPrice, sad.id, sad.count); dataGridView2.DataSource = sscio; if (dataGridView2.Rows.Count != 0) { dataGridView2.Rows[0].Selected = true; } }
private void button5_Click(object sender, EventArgs e) { SupplyAssemblyOrder order = (SupplyAssemblyOrder)dataGridView1.CurrentRow.DataBoundItem; if (dataGridView2.Rows.Count == 0) { MessageBox.Show("Заявка пуста."); return; } order.status = SupplyAssemblyOrderStatus.CREATED; DataService.db.Refresh(System.Data.Linq.RefreshMode.KeepChanges, order); DataService.db.SubmitChanges(); updateForm(); }
private void button1_Click(object sender, EventArgs e) { int count = 0; try { count = int.Parse(textBox1.Text); textBox1.Clear(); } catch (FormatException) { MessageBox.Show("Неверный формат в поле 'количества'."); } int componentId = Convert.ToInt32(dataGridView1.CurrentRow.Cells["id"].Value); ComputerComponentWithSupplier computerComponentWithSupplier = (ComputerComponentWithSupplier)dataGridView1.CurrentRow.DataBoundItem; var supplierOrder = DataService.db.GetTable <SupplyAssemblyOrder>() .Where(so => so.supplierId == computerComponentWithSupplier.supplier.id && so.status == SupplyAssemblyOrderStatus.NEW).SingleOrDefault(); if (supplierOrder == null) { DateTime now = DateTime.Now; string name = "Заказ_от_" + now.ToShortDateString(); supplierOrder = new SupplyAssemblyOrder(name, now, SupplyAssemblyOrderStatus.NEW, computerComponentWithSupplier.supplier); DataService.db.GetTable <SupplyAssemblyOrder>().InsertOnSubmit(supplierOrder); DataService.db.SubmitChanges(); } var supplyAssemblyDetails = DataService.db.GetTable <SupplyAssemblyDetails>() .Where(sad => sad.supplierStoreId == computerComponentWithSupplier.supplierStoreId && sad.supplyAssemblyOrderId == supplierOrder.id).SingleOrDefault(); if (supplyAssemblyDetails != null) { supplyAssemblyDetails.count = supplyAssemblyDetails.count + count; } else { var sad = new SupplyAssemblyDetails(count, computerComponentWithSupplier.supplierStoreId, supplierOrder.id); DataService.db.GetTable <SupplyAssemblyDetails>().InsertOnSubmit(sad); } DataService.db.SubmitChanges(); }