Beispiel #1
0
 private void frmPickListView_Load(object sender, EventArgs e)
 {
     FormLoaded        = false;
     txtCustomer.Text  = string.Empty;
     txtNo.Text        = string.Empty;
     txtTransDate.Text = string.Empty;
     FormLoaded        = true;
     PO         = null;
     RePackTran = false;
 }
Beispiel #2
0
        private void btnSubmit_Click(object sender, EventArgs e)
        {
            Button oBtn = (Button)sender;

            if (oBtn != null && Formloaded)
            {
                using (var context = new TTI2Entities())
                {
                    string BoxNumber = txtBoxNumber.Text.ToString();

                    TLCSV_StockOnHand SOH = context.TLCSV_StockOnHand.Where(x => x.TLSOH_BoxNumber == BoxNumber).FirstOrDefault();
                    if (SOH != null)
                    {
                        frmBoxView_Load(this, null);

                        txtWareHouse.Text    = context.TLADM_WhseStore.Find(SOH.TLSOH_WareHouse_FK).WhStore_Description;
                        txtColour.Text       = context.TLADM_Colours.Find(SOH.TLSOH_Colour_FK).Col_Display;
                        txtGrade.Text        = SOH.TLSOH_Grade;
                        txtSize.Text         = context.TLADM_Sizes.Find(SOH.TLSOH_Size_FK).SI_Description;
                        txtStyle.Text        = context.TLADM_Styles.Find(SOH.TLSOH_Style_FK).Sty_Description;
                        txtPickingList.Text  = SOH.TLSOH_WareHousePickList + " / " + SOH.TLSOH_PickListNo;
                        txtDeliveryNote.Text = SOH.TLSOH_WareHouseDeliveryNo + " / " + SOH.TLSOH_DNListNo;
                        txtGrade.Text        = SOH.TLSOH_Grade;
                        txtBoxedQty.Text     = SOH.TLSOH_BoxedQty.ToString();

                        TLCSV_PurchaseOrder POOrder = context.TLCSV_PurchaseOrder.Find(SOH.TLSOH_POOrder_FK);
                        if (POOrder != null)
                        {
                            txtPoOrder.Text  = POOrder.TLCSVPO_PurchaseOrder;
                            txtCustomer.Text = context.TLADM_CustomerFile.Find(POOrder.TLCSVPO_Customer_FK).Cust_Description;
                        }

                        if (!SOH.TLSOH_Write_Off)
                        {
                            chkInStock.Checked = true;

                            if (SOH.TLSOH_Picked && SOH.TLSOH_DNListNo == 0)
                            {
                                chkPicked.Checked = SOH.TLSOH_Picked;
                            }

                            if (SOH.TLSOH_Picked && SOH.TLSOH_DNListNo != 0)
                            {
                                chkInStock.Checked   = false;
                                chkDelivered.Checked = true;
                            }

                            if (SOH.TLSOH_Returned)
                            {
                                chkInStock.Checked  = true;
                                chkPicked.Checked   = SOH.TLSOH_Picked;
                                chkReturned.Checked = SOH.TLSOH_Returned;
                            }
                        }
                        else
                        {
                            chkWriteOff.Checked = true;
                        }
                    }
                    else
                    {
                        MessageBox.Show("No data matching the text as entered found");
                        frmBoxView_Load(this, null);
                    }
                }
            }
        }
Beispiel #3
0
        private void btnSubmit_Click(object sender, EventArgs e)
        {
            Button oBtn = (Button)sender;
            IList <TLCSV_StockOnHand> soh = null;

            if (oBtn != null && FormLoaded)
            {
                DataT.Rows.Clear();

                using (var context = new TTI2Entities())
                {
                    int Txt = Convert.ToInt32(txtNo.Text);
                    if (_PickList)
                    {
                        soh = context.TLCSV_StockOnHand.Where(x => x.TLSOH_PickListNo == Txt).OrderBy(x => x.TLSOH_BoxNumber).ToList();
                    }
                    else
                    {
                        soh = context.TLCSV_StockOnHand.Where(x => x.TLSOH_DNListNo == Txt).OrderBy(x => x.TLSOH_BoxNumber).ToList();
                    }


                    if (soh.Count > 0)
                    {
                        //----------------------------------------------
                        // WareHouse
                        // Box Number
                        // Purchase Order
                        // Purchase Order Date
                        // Style
                        // Colour
                        // Size
                        // Boxed Qty
                        //----------------------------------------------------------
                        var PO_Key = soh.FirstOrDefault().TLSOH_POOrder_FK;

                        PO = context.TLCSV_PurchaseOrder.Find(PO_Key);
                        if (PO != null)
                        {
                            RePackTran = PO.TLCSVPO_RepackTransaction;

                            txtCustomer.Text  = context.TLADM_CustomerFile.Find(PO.TLCSVPO_Customer_FK).Cust_Description;
                            txtTransDate.Text = PO.TLCSVPO_TransDate.ToShortDateString();
                        }

                        foreach (var Item in soh)
                        {
                            DataRow dr = DataT.NewRow();
                            dr[0] = context.TLADM_WhseStore.Find(Item.TLSOH_WareHouse_FK).WhStore_Description;
                            dr[1] = Item.TLSOH_BoxNumber;
                            var PODetail = context.TLCSV_PuchaseOrderDetail.Find(Item.TLSOH_POOrderDetail_FK);
                            if (PODetail != null)
                            {
                                dr[2] = context.TLCSV_PurchaseOrder.Find(PODetail.TLCUSTO_PurchaseOrder_FK).TLCSVPO_PurchaseOrder;
                                dr[3] = context.TLCSV_PurchaseOrder.Find(PODetail.TLCUSTO_PurchaseOrder_FK).TLCSVPO_TransDate.ToShortDateString();
                            }
                            dr[4] = context.TLADM_Styles.Find(Item.TLSOH_Style_FK).Sty_Description;
                            dr[5] = context.TLADM_Colours.Find(Item.TLSOH_Colour_FK).Col_Display;
                            dr[6] = context.TLADM_Sizes.Find(Item.TLSOH_Size_FK).SI_Description;
                            dr[7] = Item.TLSOH_BoxedQty;

                            DataT.Rows.Add(dr);
                        }
                    }
                    else
                    {
                        using (DialogCenteringService centeringService = new DialogCenteringService(this)) // center message box
                        {
                            MessageBox.Show("No records found for selection made");
                        }


                        txtCustomer.Text  = string.Empty;
                        txtTransDate.Text = string.Empty;
                    }
                }
            }
        }
Beispiel #4
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            Button oBtn = (Button)sender;

            if (oBtn != null && FormLoaded)
            {
                Number = txtPONumber.Text.Substring(-4 + txtPONumber.Text.TrimEnd().Length, 4);
                //===========================================================================
                // We have to put in some form of logic to sum the various columns
                // and conmpare to PODetails and if there is a difference warn the user and abort
                //===============================================================================================
                using (var context = new TTI2Entities())
                {
                    foreach (DataColumn dc in dt.Columns)
                    {
                        if (dc.Ordinal > 0 && dc.Ordinal < -1 + dt.Columns.Count)
                        {
                            var ColTotal = 0;

                            try
                            {
                                foreach (DataRow dr in dt.Rows)
                                {
                                    ColTotal += dr.Field <int>(dc.Ordinal) * dr.Field <int>(-1 + dt.Columns.Count);
                                }
                            }
                            catch (Exception ex)
                            {
                                MessageBox.Show(ex.Message.ToString());
                                return;
                            }

                            var SizePk = Convert.ToInt32(dc.ColumnName);

                            var SizeDetail = PODetails.Where(x => x.TLCUSTO_Size_FK == SizePk).FirstOrDefault();
                            if (SizeDetail != null)
                            {
                                if (ColTotal != SizeDetail.TLCUSTO_Qty)
                                {
                                    var TLSizes = context.TLADM_Sizes.Find(SizePk);
                                    if (TLSizes != null)
                                    {
                                        var Message    = "There is a difference between what was ordered and what was captured for Size " + TLSizes.SI_Description;
                                        var TopMessage = "Ordered " + SizeDetail.TLCUSTO_Qty.ToString() + " vs a Repack value " + ColTotal.ToString();
                                        using (DialogCenteringService centeringService = new DialogCenteringService(this)) // center message box
                                        {
                                            MessageBox.Show(Message, TopMessage, MessageBoxButtons.OK, MessageBoxIcon.Error);
                                        }
                                        return;
                                    }
                                }
                            }
                        }
                    }

                    PO = context.TLCSV_PurchaseOrder.Find(_PurchaseKey);
                    if (PO != null)
                    {
                        PO.TLCSVPO_RepackTransaction = true;
                    }

                    foreach (DataRow Row in dt.Rows)
                    {
                        int CellTotals = 0;
                        foreach (DataColumn dc in dt.Columns)
                        {
                            if (dc.DataType == typeof(String))
                            {
                                continue;
                            }

                            CellTotals += Row.Field <int>(dc.Ordinal);
                        }

                        if (CellTotals == 0)
                        {
                            continue;
                        }


                        foreach (DataColumn dc in dt.Columns)
                        {
                            try
                            {
                                var SizeSelected = Convert.ToInt32(dc.ColumnName);
                                var SizeObject   = context.TLADM_Sizes.Find(SizeSelected);
                                if (SizeObject != null)
                                {
                                    TLCSV_RePackConfig RePac = new TLCSV_RePackConfig();
                                    RePac.PORConfig_PONumber_Fk   = _PurchaseKey;
                                    RePac.PORConfig_Colour_FK     = ColourPk;
                                    RePac.PORConfig_Style_FK      = StylePk;
                                    RePac.PORConfig_Size_FK       = SizeObject.SI_id;
                                    RePac.PORConfig_SizeBoxQty    = Row.Field <int>(dc.Ordinal);
                                    RePac.PORConfig_TotalBoxes    = Row.Field <int>(dt.Columns.Count - 1);
                                    RePac.PORConfig_BoxNumber     = Row.Field <string>(0);
                                    RePac.PORConfig_Display       = Row.Field <String>(0) + " : " + SizeObject.SI_Description;
                                    RePac.PORConfig_BoxNumber_Key = Convert.ToInt32(Number);
                                    context.TLCSV_RePackConfig.Add(RePac);
                                }
                            }
                            catch (Exception ex)
                            {
                                continue;
                            }
                        }
                    }

                    try
                    {
                        context.SaveChanges();
                        MessageBox.Show("Data successfully saved to the database");
                        this.Close();
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message);
                    }
                }
            }
        }