コード例 #1
0
        public bool Issue()
        {
            if (this.Order.OrderID == SelectedOrder.OrderID)
            {
                MaterialsFromStock newIssue = DBResources.Instance.Context.MaterialsFromStocks.Create();
                newIssue.Order = this.Order;
                newIssue.Order1 = this.SelectedOrder;
                newIssue.Quantity = IssueQuantity;
                newIssue.IssuedDate = DBResources.Instance.GetServerTime();
                newIssue.MaterialStock = SelectedMaterialStock;
                SelectedMaterialStock.IssuedQuantityWrapper += IssueQuantity;
                this.Order.MaterialsFromStocks.Add(newIssue);
            }
            else
            {
                MaterialStock stockInOtherOrder = null;
                foreach (MaterialStock stock in SelectedOrder.MaterialStocks)
                {
                    if (stock.SubMaterial == SelectedMaterialStock.SubMaterial)
                    {
                        stockInOtherOrder = stock;
                        break;
                    }
                }

                if (stockInOtherOrder == null)
                {
                    stockInOtherOrder = new MaterialStock();
                    stockInOtherOrder.Order = this.SelectedOrder;
                    stockInOtherOrder.SubMaterial = SelectedMaterialStock.SubMaterial;
                    stockInOtherOrder.InStockDateTime = DBResources.Instance.GetServerTime();
                    stockInOtherOrder.StockQuantity = 0;
                    stockInOtherOrder.UnitsOfMeasurement = SelectedMaterialStock.UnitsOfMeasurement;
                    stockInOtherOrder.SubMaterial.MaterialStocks.Add(stockInOtherOrder);

                    this.SelectedOrder.MaterialStocks.Add(stockInOtherOrder);
                }

                stockInOtherOrder.StockQuantity += IssueQuantity;

                //To Record
                MaterialsFromStock to = DBResources.Instance.Context.MaterialsFromStocks.Create();
                to.Order = this.Order;
                to.Order1 = this.SelectedOrder;
                to.Quantity = IssueQuantity;
                to.IssuedDate = DBResources.Instance.GetServerTime();
                to.MaterialStock = SelectedMaterialStock;
                SelectedMaterialStock.IssuedQuantityWrapper += IssueQuantity;
                this.Order.MaterialsFromStocks.Add(to);

                //From Record
                MaterialsFromStock from = DBResources.Instance.Context.MaterialsFromStocks.Create();
                from.Order = this.Order;
                from.Order1 = this.SelectedOrder;
                from.Quantity = IssueQuantity;
                from.IssuedDate = DBResources.Instance.GetServerTime();
                from.MaterialStock = stockInOtherOrder;
                stockInOtherOrder.MaterialsFromStocks.Add(from);



            }
            return DBResources.Instance.Save();
        }
コード例 #2
0
        private void MenuItem_Click_1(object sender, RoutedEventArgs e)
        {
            MenuItem item = sender as MenuItem;
            switch (item.Header.ToString())
            {
                case "Knitting":
                case "Dyeing":
                case "Compacting":
                    CreateJoWindow newJobOrder = new CreateJoWindow();
                    newJobOrder.Order = ViewModel.Order;
                    newJobOrder.Quantity = ViewModel.SelectedItem.SelectedQuantity;
                    newJobOrder.GRNRefNo = ViewModel.SelectedItem.GRNreceiptNumbers;
                    newJobOrder.Initialize(item.Header.ToString());
                    if (newJobOrder.ShowDialog() == true)
                    {
                        byte receiptStatus = 1;
                        string headerString = item.Header.ToString();
                        if (headerString == "Knitting")
                            receiptStatus = (byte)RecieptStatus.IssuedToKnittting;
                        else if (headerString == "Dyeing")
                            receiptStatus = (byte)RecieptStatus.IssuedToDyeing;
                        else if (headerString == "Compacting")
                            receiptStatus = (byte)RecieptStatus.IssuedToCompacting;
                        foreach (var receipt in ViewModel.SelectedItem.GRNReceipts)
                            receipt.ReceiptStatusID = receiptStatus;

                        DBResources.Instance.Save();
                        ViewModel.ResetData();
                    }
                    break;
                case "Printing":
                case "Washing":
                case "Other":
                case "Stock":
                        
                        IssueToPopupBox issuePopupBox = new IssueToPopupBox(DBResources.Instance.AllJobsTypes, item.Header.ToString());
                        issuePopupBox.JobQuantity = issuePopupBox.Receipt.QualityPassedQuantityWrapper;

                        if (issuePopupBox.ShowDialog() == true)
                        {
                            if (issuePopupBox.JobOrder.JobOrderType.Type.ToLower() == "stock")
                            {
                                OrderedItem firstOrderedItem = ViewModel.SelectedItem.GRNReceipts.First().OrderedItem;
                                SubMaterial subMaterial = firstOrderedItem.SubMaterial;
                                MaterialStock stock = new MaterialStock();
                                stock.Order = ViewModel.Order;
                                stock.SubMaterial = subMaterial;
                                stock.InStockDateTime = DBResources.Instance.GetServerTime();
                                stock.StockQuantity = ViewModel.SelectedItem.SelectedQuantity;
                                stock.UnitsOfMeasurement = firstOrderedItem.ProductMaterialItem.UnitsOfMeasurementWrapper;
                                subMaterial.MaterialStocks.Add(stock);
                                foreach (var receipt in ViewModel.SelectedItem.GRNReceipts)
                                    receipt.ReceiptStatusID = (byte)RecieptStatus.IssuedToStock;
                            }
                            else
                            {
                                foreach(var receipt in ViewModel.SelectedItem.GRNReceipts)
                                    receipt.JobOrders.Add(issuePopupBox.JobOrder);
                            }

                            DBResources.Instance.Save();
                            ViewModel.ResetData();
                            foreach (var receipt in ViewModel.SelectedItem.GRNReceipts)
                                receipt.RefreshUIEnablers();
                        }
                    break;
            }

            foreach (var receipt in ViewModel.SelectedItem.GRNReceipts)
                receipt.RefreshUIEnablers();

            
        }
コード例 #3
0
        private void MenuItem_Click_1(object sender, RoutedEventArgs e)
        {
            MenuItem item = sender as MenuItem;
            DependencyObject obj = item.GetParentObject();
            switch (item.Header.ToString())
            {
                case "Send To Store":
                    ReceiptStatu recievedStatus = DBResources.Instance.Context.ReceiptStatus.Find(10);
                    selectedGRNReciept.ReceiptStatu = recievedStatus;
                    DBResources.Instance.Save();
                    break;
                case "Knitting":
                    CreateJoWindow knittWindow = new CreateJoWindow();
                    knittWindow.Order = this.selectedGRNReciept.OrderedItem.PurchaseOrder.Order;
                    knittWindow.PurchaseOrder = this.selectedGRNReciept.OrderedItem.PurchaseOrder;
                    knittWindow.Quantity = this.selectedGRNReciept.QualityPassedQuantity.Value;
                    knittWindow.GRNRefNo = this.selectedGRNReciept.GRNReciptID.ToString();
                    knittWindow.GRNReciept = this.selectedGRNReciept;
                    knittWindow.InitializeForKnitting();
                    knittWindow.ShowDialog();
                    break;
                case "Dyeing":
                    CreateJoWindow dyeWindow = new CreateJoWindow();
                    dyeWindow.Order = this.selectedGRNReciept.OrderedItem.PurchaseOrder.Order;
                    dyeWindow.PurchaseOrder = this.selectedGRNReciept.OrderedItem.PurchaseOrder;
                    dyeWindow.Quantity = this.selectedGRNReciept.QualityPassedQuantity.Value;
                    dyeWindow.GRNRefNo = this.selectedGRNReciept.GRNReciptID.ToString();
                    dyeWindow.GRNReciept = this.selectedGRNReciept;
                    dyeWindow.InitializeForDyeing();
                    dyeWindow.ShowDialog();
                    break;
                case "Compacting":
                    CreateJoWindow compactingWindow = new CreateJoWindow();
                    compactingWindow.Order = this.selectedGRNReciept.OrderedItem.PurchaseOrder.Order;
                    compactingWindow.PurchaseOrder = this.selectedGRNReciept.OrderedItem.PurchaseOrder;
                    compactingWindow.Quantity = this.selectedGRNReciept.QualityPassedQuantity.Value;
                    compactingWindow.GRNRefNo = this.selectedGRNReciept.GRNReciptID.ToString();
                    compactingWindow.GRNReciept = this.selectedGRNReciept;
                    compactingWindow.InitializeForCompacting();
                    compactingWindow.ShowDialog();
                    break;
                case "Printing":
                case "Washing":
                case "Other":
                case "Stock":
                    if (selectedGRNReciept != null)
                    {
                        GRNReciept receipt = selectedGRNReciept;
                        IssueToPopupBox issuePopupBox = new IssueToPopupBox(DBResources.Instance.AllJobsTypes, item.Header.ToString());
                        issuePopupBox.Receipt = receipt;
                        issuePopupBox.JobQuantity = issuePopupBox.Receipt.QualityPassedQuantityWrapper;

                        if (issuePopupBox.ShowDialog() == true)
                        {
                            if (issuePopupBox.JobOrder.JobOrderType.Type.ToLower() == "stock")
                            {
                                MaterialStock stock = new MaterialStock();
                                stock.Order = ViewModel.Order;
                                stock.SubMaterial = ViewModel.OrderedItem.ProductMaterialItem.SubMaterial;
                                stock.InStockDateTime = DBResources.Instance.GetServerTime();
                                stock.StockQuantity = receipt.QualityPassedQuantityWrapper;
                                stock.UnitsOfMeasurement = ViewModel.OrderedItem.ProductMaterialItem.UnitsOfMeasurementWrapper;
                                ViewModel.OrderedItem.ProductMaterialItem.SubMaterial.MaterialStocks.Add(stock);
                                receipt.ReceiptStatusID = (byte)RecieptStatus.IssuedToStock;
                            }
                            else
                            {
                                receipt.JobOrders.Add(issuePopupBox.JobOrder);
                            }

                            DBResources.Instance.Save();
                            ViewModel.SelectedGRNReceipt.RefreshUIEnablers();
                        }
                    }
                    break;
            }

            ViewModel.SelectedGRNReceipt.RefreshUIEnablers();
        }
コード例 #4
0
        public bool IssueNewJob(JobOrder jobOrder)
        {
            bool res = false;
            if (jobOrder != null)
            {
                if (jobOrder.JobOrderType.Type.ToLower() == "stock")
                {
                    if (jobOrder.GRNReciept != null)
                    {
                        if (jobOrder.GRNReciept.OrderedItem.ProductMaterialItem.SubMaterial.InStock == null)
                            jobOrder.GRNReciept.OrderedItem.ProductMaterialItem.SubMaterial.InStock = 0;

                        MaterialStock stock = new MaterialStock();
                        stock.Order = this.Order;
                        stock.SubMaterial = jobOrder.GRNReciept.OrderedItem.ProductMaterialItem.SubMaterial;
                        stock.InStockDateTime = DBResources.Instance.GetServerTime();
                        stock.StockQuantity = jobOrder.JobQuantity;
                        stock.UnitsOfMeasurement = jobOrder.GRNReciept.OrderedItem.ProductMaterialItem.UnitsOfMeasurementWrapper;
                        jobOrder.GRNReciept.OrderedItem.ProductMaterialItem.SubMaterial.MaterialStocks.Add(stock);
                        jobOrder.GRNReciept.OrderedItem.ProductMaterialItem.SubMaterial.InStock += jobOrder.JobQuantity;
                    }
                    else
                        return false;
                }
                else
                {
                    jobOrder.GRNReciept.JobOrders.Add(jobOrder);
                }
                res = Save();
                if (res)
                    jobOrder.Refresh();
            }
            return res;
        }