Ejemplo n.º 1
0
        public void Delete(String id)
        {
            BUS_InventoryExportDetail detail = new BUS_InventoryExportDetail();
            BUS_InventoryExport       export = new BUS_InventoryExport();

            detail.Delete(id);
            export.Delete(id);
            LoadData();
        }
        private void btSave_Click(object sender, RoutedEventArgs e)
        {
            if (list.Count.Equals(0))
            {
                MessageBox.Show($"Danh sách nguyên vật liệu, thiết bị không được để trống!");
                return;
            }
            foreach (InventoryObject obj in list)
            {
                int amountInExport; int temp1 = -1, temp2 = -1;
                if (int.TryParse(obj.amount, out amountInExport))
                {
                    if (mapNameAmountInStock[obj.name] < amountInExport)
                    {
                        MessageBox.Show($"Số lượng của '{obj.name}' trong kho chỉ còn {mapNameAmountInStock[obj.name]}!");
                        return;
                    }
                }
                if (!int.TryParse(obj.amount, out temp2) || temp2 <= 0)
                {
                    MessageBox.Show($"Số lượng của {obj.name} không hợp lệ!");
                    return;
                }
                //if (tbDescription.Text.Length == 0)
                //{
                //    MessageBox.Show($"Vui lòng nhập lí do !");
                //    return;
                //}
                string temp = $"insert into InventoryExportDetail values ('{selectionID}','{obj.id}','{obj.amount}')";
                sqlCommand.Add(temp);
            }
            BUS_InventoryExport export = new BUS_InventoryExport();

            export.updateDescription(selectionID, tbDescription.Text);
            BUS_InventoryExportDetail detail = new BUS_InventoryExportDetail();

            detail.Delete(selectionID);
            detail.ImportList(sqlCommand);
            var screen = new InventoryExport(_context);

            if (screen != null)
            {
                this._context.StackPanelMain.Children.Clear();
                this._context.StackPanelMain.Children.Add(screen);
            }
        }