コード例 #1
0
        private void RadGridView1_SelectionChanged(object sender, SelectionChangeEventArgs e)
        {
            try
            {
                if (gridBox.SelectedItems.Count > 0)
                {
                    tbl_BoxMaster _tb = gridBox.SelectedItem as tbl_BoxMaster;

                    _boxcode = _tb.BoxCode;

                    gridPartitionMaster.ItemsSource = dbContext.tbl_PartitionMaster.Where(x => x.BoxCode == _boxcode).ToList();

                    contPartition.IsEnabled = true;

                    btnAddQuantity.IsEnabled = true;

                    var countInventory = dbContext.tbl_BoxSeries.Count(p => p.BoxCode == _boxcode);

                    var countPartition = dbContext.tbl_PartitionSeries.Count(p => p.BoxCode == _boxcode);

                    if (countInventory == 0 || countPartition == 0)
                    {
                        btnIssueBox.IsEnabled = false;

                        MessageBox.Show("No Inventory Of Box And Partition For " + _boxcode);
                    }
                    else
                    {
                        btnIssueBox.IsEnabled = true;
                    }


                    if (gridPartitionMaster.Items.Count > 0)
                    {
                        btnNewPartition.IsEnabled = false;

                        btnAddPartitionQuantity.IsEnabled = false;
                    }
                    else
                    {
                        btnNewPartition.IsEnabled = true;

                        btnAddPartitionQuantity.IsEnabled = false;
                    }
                }
            }
            catch
            {
            }
        }
コード例 #2
0
        private void GetBoxCode()
        {
            var a = dbContext.tbl_BoxSeries.Where(x => x.BoxCode + "-" + x.SeriesNo.ToString() == tbCode.Text.Trim()).FirstOrDefault();

            tbl_BoxSeries tbl = a as tbl_BoxSeries;

            _boxcodes = tbl.BoxCode;

            var b = dbContext.tbl_BoxMaster.Where(x => x.BoxCode == _boxcodes).FirstOrDefault();

            tbl_BoxMaster tbl2 = b as tbl_BoxMaster;

            _usage = tbl2.UsagePerBox.GetValueOrDefault();
        }
コード例 #3
0
        private void Issue()
        {
            var a = dbContext.tbl_BoxMaster.Where(t => t.BoxCode == _boxcode).FirstOrDefault();

            tbl_BoxMaster _tb = a as tbl_BoxMaster;

            _usage = _tb.UsagePerBox.GetValueOrDefault();

            var countInventory = dbContext.tbl_BoxSeries.Count(p => p.BoxCode == _boxcode && p.IsUsed == false);

            var countInventory_Partition = dbContext.tbl_PartitionSeries.Count(p => p.BoxCode == _boxcode && p.IsUsed == false);


            int QtyInStock_Box       = countInventory;
            int QtyInStock_Partition = countInventory_Partition;
            int neededBox            = Convert.ToInt32(tbQty.Value);
            int neededPartition      = neededBox * _usage;


            if (QtyInStock_Box >= neededBox)
            {
                if (QtyInStock_Partition >= neededPartition)
                {
                    IssueBox(neededBox);

                    IssuePartition(neededPartition);

                    LoadData();
                    tbQty.Value = 0;

                    string empname = string.Empty;

                    var empdata = dbHRIS.SKPI_GetAllEmployeesByEmpID(_empID).ToList();

                    foreach (DataRow dr in ConvertToDataTable(empdata).Rows)
                    {
                        empname = dr["FullName_LnameFirst"].ToString();
                    }

                    tbl_TransactionMaster transact = new tbl_TransactionMaster()
                    {
                        TransactBy         = empname,
                        TransactionDetails = "Preparing for Box Issuance",
                        CreationDateTime   = DateTime.Now
                    };

                    dbContext.tbl_TransactionMaster.Add(transact);

                    dbContext.SaveChanges();

                    MessageBox.Show("Records Ready For Scanning");
                }
                else
                {
                    int boxtogive = QtyInStock_Partition / _usage;

                    int partitionToGive = boxtogive * _usage;

                    IssueBox(boxtogive);

                    IssuePartition(partitionToGive);

                    LoadData();
                    tbQty.Value = 0;

                    string empname = string.Empty;

                    var empdata = dbHRIS.SKPI_GetAllEmployeesByEmpID(_empID).ToList();

                    foreach (DataRow dr in ConvertToDataTable(empdata).Rows)
                    {
                        empname = dr["FullName_LnameFirst"].ToString();
                    }

                    tbl_TransactionMaster transact = new tbl_TransactionMaster()
                    {
                        TransactBy         = empname,
                        TransactionDetails = "Preparing for Box Issuance",
                        CreationDateTime   = DateTime.Now
                    };

                    dbContext.tbl_TransactionMaster.Add(transact);

                    dbContext.SaveChanges();

                    MessageBox.Show("Records Ready For Scanning");
                }
            }
            else if (QtyInStock_Box < neededBox && QtyInStock_Box > 0)
            {
                int boxtogive = QtyInStock_Box;

                int partitionToGive = boxtogive * _usage;

                IssueBox(boxtogive);

                IssuePartition(partitionToGive);

                LoadData();
                tbQty.Value = 0;

                string empname = string.Empty;

                var empdata = dbHRIS.SKPI_GetAllEmployeesByEmpID(_empID).ToList();

                foreach (DataRow dr in ConvertToDataTable(empdata).Rows)
                {
                    empname = dr["FullName_LnameFirst"].ToString();
                }

                tbl_TransactionMaster transact = new tbl_TransactionMaster()
                {
                    TransactBy         = empname,
                    TransactionDetails = "Preparing for Box Issuance",
                    CreationDateTime   = DateTime.Now
                };

                dbContext.tbl_TransactionMaster.Add(transact);

                dbContext.SaveChanges();

                MessageBox.Show("Records Ready For Scanning");
            }

            else
            {
                MessageBox.Show("Cannot issue box. No available stocks");
                LoadData();
                tbQty.Value = 0;
            }



            //if (countInventory >= Convert.ToInt32(tbQty.Value))
            //{
            //    //Count Box
            //    int QtyInStock = countInventory;
            //    int neededQty = Convert.ToInt32(tbQty.Value);

            //    int div = QtyInStock / neededQty; //quotient
            //    int mod = QtyInStock % neededQty; //remainder

            //    //Check Partition
            //    //Needed Partition
            //    int totalPartition = QtyInStock * _usage;

            //    //Count Partition
            //    var countInventory_Partition = dbContext.tbl_PartitionSeries.Count(p => p.BoxCode == _boxcode && p.IsUsed == false);

            //    int divPartition = countInventory_Partition / totalPartition; //quotient
            //    int modPartition = countInventory_Partition % totalPartition; //remainder


            //    //If stock partition is greater than the quantity needed
            //    if (countInventory_Partition > totalPartition)
            //    {
            //        //if (modPartition > 0)
            //        //{
            //        //MessageBoxResult results = MessageBox.Show("Cannot issue some partitions." + Environment.NewLine
            //        //    + "Total Box To Be Issued: " + QtyInStock + Environment.NewLine
            //        //    + "Total Partitions To Be Issued: " + divPartition + Environment.NewLine
            //        //    //+ "Remaining Quantity From Needed Quantity: " + modPartition.ToString().Trim() + Environment.NewLine
            //        //    + "Do you want to continue?", "Confirmation", MessageBoxButton.YesNo, MessageBoxImage.Question);

            //        //if (results == MessageBoxResult.Yes)
            //        //{
            //        //    // Do this
            //        //    //Set As Issued
            //        //    var dataBox = dbContext.tbl_BoxSeries.Where(p => p.BoxCode == _boxcode && p.IsUsed == false).Take(QtyInStock).ToList();

            //        //    dataBox.ForEach(p => p.IsUsed = true);

            //        //    dbContext.SaveChanges();


            //        //    //Set as Issued
            //        //    var dataPartition = dbContext.tbl_PartitionSeries.Where(p => p.BoxCode == _boxcode && p.IsUsed == false).Take(divPartition).ToList();

            //        //    dataBox.ForEach(p => p.IsUsed = true);

            //        //    dbContext.SaveChanges();

            //        //    MessageBox.Show("Record Successfully Saved");
            //        //}

            //        //}
            //        //else
            //        //{

            //        // Do this
            //        //Set As Issued
            //        IssueBox(QtyInStock);

            //        //Set as Issued
            //        IssuePartition(totalPartition);

            //        MessageBox.Show("Record Successfully Saved");
            //        //}
            //    }
            //    else
            //    {
            //        int boxToBeFilled = countInventory_Partition / _usage;

            //        int partTogive = boxToBeFilled * _usage;

            //        MessageBoxResult result = MessageBox.Show("The remaining partitions will no longer be sufficient to fill the required quantity? " +
            //            "Needed Partition: " + totalPartition.ToString().Trim() + Environment.NewLine +
            //            "Remaining Partition: " + countInventory_Partition.ToString().Trim() + Environment.NewLine +
            //            "Boxes To Be Filled By Remaining Quantity: " + boxToBeFilled.ToString().Trim() + Environment.NewLine +
            //            "Do you want to continue?", "Confirmation", MessageBoxButton.YesNo, MessageBoxImage.Question);

            //        if (result == MessageBoxResult.Yes)
            //        {
            //            // Do this
            //            //Set As Issued
            //            IssueBox(boxToBeFilled);

            //            //Set as Issued
            //            IssuePartition(partTogive);
            //        }
            //    }

            //}
            //else if (countInventory == 0)
            //{
            //    MessageBox.Show("Cannot issue box. No available stocks");
            //    tbQty.Value = 0;
            //}
            //else
            //{
            //    //Count Box
            //    var countInventoryRemaining = dbContext.tbl_BoxSeries.Count(p => p.BoxCode == _boxcode && p.IsUsed == false);

            //    MessageBoxResult result = MessageBox.Show("Needed quantity is more than the stock boxes? " + Environment.NewLine +
            //        "Needed Quantity: " + tbQty.Value.ToString().Trim() + Environment.NewLine +
            //        "Remaining Quantity: " + countInventoryRemaining.ToString().Trim() + Environment.NewLine +
            //        "Do you want to continue?", "Confirmation", MessageBoxButton.YesNo, MessageBoxImage.Question);

            //    if (result == MessageBoxResult.Yes)
            //    {
            //        //Check Partition
            //        //Needed Partition
            //        int totalPartition = countInventoryRemaining * _usage;

            //        //Count Partition
            //        var countInventory_Partition = dbContext.tbl_PartitionSeries.Count(p => p.BoxCode == _boxcode && p.IsUsed == false);

            //        int divPartition = countInventory_Partition / totalPartition; //quotient
            //        int modPartition = countInventory_Partition % totalPartition; //remainder

            //        //If stock partition is greater than the quantity needed
            //        if (countInventory_Partition > totalPartition)
            //        {
            //            if (modPartition > 0)
            //            {
            //                MessageBoxResult results = MessageBox.Show("Cannot issue some partitions." + Environment.NewLine
            //                    + "Total Box To Be Issued: " + countInventoryRemaining + Environment.NewLine
            //                    + "Total Partitions To Be Issued: " + divPartition + Environment.NewLine
            //                    + "Remaining Quantity From Needed Quantity: " + modPartition.ToString().Trim() + Environment.NewLine
            //                    + "Do you want to continue?", "Confirmation", MessageBoxButton.YesNo, MessageBoxImage.Question);

            //                if (results == MessageBoxResult.Yes)
            //                {
            //                    // Do this
            //                    //Set As Issued
            //                    IssueBox(countInventoryRemaining);

            //                    //Set as Issued
            //                    IssuePartition(divPartition);

            //                    MessageBox.Show("Record Successfully Saved");
            //                }
            //            }
            //            else
            //            {
            //                // Do this
            //                //Set As Issued
            //                IssueBox(countInventoryRemaining);

            //                //Set as Issued
            //                IssuePartition(divPartition);


            //                MessageBox.Show("Record Successfully Saved");
            //            }
            //        }
            //        else
            //        {
            //            if (_usage < divPartition)
            //            {
            //                MessageBox.Show("Cannot Issue Box");
            //            }
            //            else
            //            {
            //                int boxToBeFilled = countInventory_Partition / _usage;

            //                int partTogive = boxToBeFilled * _usage;

            //                if (boxToBeFilled >= countInventoryRemaining && boxToBeFilled != 0)
            //                {
            //                    MessageBoxResult result3 = MessageBox.Show("The remaining partitions will no longer be sufficient to fill the required quantity? " +
            //                        "Needed Partition: " + totalPartition.ToString().Trim() + Environment.NewLine +
            //                        "Remaining Partition: " + countInventory_Partition.ToString().Trim() + Environment.NewLine +
            //                        "Boxes To Be Filled By Remaining Quantity: " + boxToBeFilled.ToString().Trim() + Environment.NewLine +
            //                        "Do you want to continue?", "Confirmation", MessageBoxButton.YesNo, MessageBoxImage.Question);

            //                    if (result3 == MessageBoxResult.Yes)
            //                    {
            //                        // Do this
            //                        //Set As Issued
            //                        IssueBox(boxToBeFilled);

            //                        //Set as Issued
            //                        IssuePartition(partTogive);
            //                    }
            //                }
            //                else
            //                {
            //                    MessageBox.Show("Cannot Issue Box");
            //                }
            //            }
            //        }
            //    }
            //}
        }
コード例 #4
0
        private Boolean Insert()
        {
            Boolean _result = false;

            _result = _isValidFields();

            if (!_result)
            {
                return(false);
            }

            bool isexists = dbContext.tbl_BoxMaster.Any(x => x.BoxCode == tbBoxCode.Text.Trim());

            if (!isexists)
            {
                tbl_BoxMaster _tb = new tbl_BoxMaster()
                {
                    BoxCode = tbBoxCode.Text,

                    BoxDescription = tbBoxDesc.Text,

                    UsagePerBox = Convert.ToInt32(tbUsage.Value),

                    ItemTag = tbItemTag.Text,

                    CusCode = cboCustomer.SelectedValue.ToString()
                };

                dbContext.tbl_BoxMaster.Add(_tb);

                dbContext.SaveChanges();


                string empname = string.Empty;

                var empdata = dbHRIS.SKPI_GetAllEmployeesByEmpID(_empID).ToList();

                foreach (DataRow dr in ConvertToDataTable(empdata).Rows)
                {
                    empname = dr["FullName_LnameFirst"].ToString();
                }

                tbl_TransactionMaster transact = new tbl_TransactionMaster()
                {
                    TransactBy         = empname,
                    TransactionDetails = "New Item Inserted: " + tbBoxCode.Text.Trim(),
                    CreationDateTime   = DateTime.Now
                };

                dbContext.tbl_TransactionMaster.Add(transact);

                dbContext.SaveChanges();


                BoxAndPartitionMaster.gridBox.ItemsSource = dbContext.tbl_BoxMaster.ToList();

                MessageBox.Show("Record successfully saved");

                tbBoxCode.Text = tbBoxDesc.Text = tbItemTag.Text = string.Empty;

                cboCustomer.SelectedIndex = -1;

                tbBoxCode.Focus();
            }
            else
            {
            }

            return(true);
        }