Пример #1
0
        private void btnSubmit_Click(object sender, EventArgs e)
        {
            Button oBtn = (Button)sender;

            if (!_Export)
            {
                var Depts = (TLADM_Departments)cmboDepartments.SelectedItem;
                if (Depts == null)
                {
                    using (DialogCenteringService svces = new DialogCenteringService(this))
                    {
                        MessageBox.Show("Please select a CMT to report on");
                        return;
                    }

                }
                CMTReportOptions repOps = new CMTReportOptions();
                repOps.SLFCmt = Depts.Dep_Id;

                DateTime dt = Convert.ToDateTime(dtpToDate.Value.ToShortDateString());
                repOps.toDate = dt.AddHours(23);
                // repOps.toDate = (DateTimedtpToDate.Value;

                frmCMTViewRep vRep = new frmCMTViewRep(18, repOps);
                int h = Screen.PrimaryScreen.WorkingArea.Height;
                int w = Screen.PrimaryScreen.WorkingArea.Width;
                vRep.ClientSize = new Size(w, h);
                vRep.ShowDialog(this);
            }
        }
Пример #2
0
 private void ShowMessagebox(string Message)
 {
     using (DialogCenteringService centeringService = new DialogCenteringService(this)) // center message box
     {
         MessageBox.Show(this, Message);
     }
 }
Пример #3
0
        private void dataGridView1_CellValidating(object sender, DataGridViewCellValidatingEventArgs e)
        {
            DataGridView oDgv = (DataGridView)sender;

            if (oDgv != null && formloaded)
            {
                if (e.ColumnIndex == 3)
                {
                    decimal wt = 0.0M;
                    decimal.TryParse(e.FormattedValue.ToString(), out wt);
                    if (wt > 0)
                    {
                        var KnitOrder = (TLKNI_Order)cmboKnitOrders.SelectedItem;
                        if (KnitOrder != null)
                        {
                            using (var context = new TTI2Entities())
                            {
                                var Qual = context.TLADM_Griege.Find(KnitOrder.KnitO_Product_FK);
                                if (Qual != null)
                                {
                                    var MinWeightAllowed = Qual.TLGreige_KgPerPiece / Convert.ToDecimal(1.25);
                                    var MaxWeightAllowed = Qual.TLGreige_KgPerPiece * Convert.ToDecimal(1.25);
                                    if (wt > MaxWeightAllowed)
                                    {
                                        String s = String.Format("The maximum weight permitted is {0} ", Math.Round(MaxWeightAllowed, 2));
                                        using (DialogCenteringService centeringService = new DialogCenteringService(this))  // center message box
                                        {
                                            MessageBox.Show("The value entered exceeds the maximum weight allowed", s);
                                        }
                                        e.Cancel = true;
                                    }
                                    else if (wt < MinWeightAllowed)
                                    {
                                        String s = String.Format("The minimum weight permitted is {0} ", Math.Round(MinWeightAllowed, 2));
                                        using (DialogCenteringService centeringService = new DialogCenteringService(this)) // center message box
                                        {
                                            DialogResult res = MessageBox.Show("The value entered is less than the minimum weight expected. Proceed ?", s, MessageBoxButtons.YesNo, MessageBoxIcon.Error);
                                            if (res == DialogResult.No)
                                            {
                                                e.Cancel = true;
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                    else
                    {
                        using (DialogCenteringService centeringService = new DialogCenteringService(this))  // center message box
                        {
                            MessageBox.Show("Please enter a value");
                        }
                        e.Cancel = true;
                    }
                }
            }
        }
Пример #4
0
        private void rbNonCompliance_CheckedChanged(object sender, EventArgs e)
        {
            RadioButton oRad = (RadioButton)sender;

            if (oRad != null && oRad.Checked && FormLoaded)
            {
                using (DialogCenteringService centeringService = new DialogCenteringService(this)) // center message box
                {
                    MessageBox.Show("Work in Progress");
                }
            }
        }
Пример #5
0
        private void frmOnOffHold_FormClosing(object sender, FormClosingEventArgs e)
        {
            Form oFrm = (Form)sender;

            if (oFrm != null && this.RememberSave)
            {
                using (DialogCenteringService centeringService = new DialogCenteringService(this)) // center message box
                {
                    MessageBox.Show("There is a transaction that must be saved prior to existing this transaction");
                    e.Cancel = true;
                }
            }
        }
Пример #6
0
        private void UpdateNotifcationClick()
        {
            //Prompt once for the user to update the tool.
            DialogResult result;

            using (DialogCenteringService centeringService = new DialogCenteringService(this)) // center message box
            {
                result = MessageBox.Show($"A new update is available {UpdateProgram.LatestRelease.TagName}!" +
                                         $" Would you like to install it?", "Updater", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1);
            }
            if (result == DialogResult.Yes)
            {
                UpdateApplication();
            }
        }
Пример #7
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            Button oBtn = sender as Button;

            if (oBtn != null && FormLoaded)
            {
                using (var context = new TTI2Entities())
                {
                    foreach (DataRow Row in ExistingDyeBatches.Rows)
                    {
                        if (!Row.Field <bool>(1))
                        {
                            continue;
                        }

                        var Pk = Row.Field <int>(0);

                        var DB = context.TLDYE_DyeBatch.Find(Pk);
                        if (DB != null)
                        {
                            DB.DYEB_Closed = true;
                        }
                    }

                    try
                    {
                        context.SaveChanges();
                        using (DialogCenteringService centeringService = new DialogCenteringService(this)) // center message box
                        {
                            MessageBox.Show("Data successfully stored to the database");
                        }
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message);
                    }
                    finally
                    {
                        this.frmCloseDyeBatches_Load(this, null);
                    }
                }
            }
        }
Пример #8
0
        private void dataGridViewx_CellValidating(object sender, DataGridViewCellValidatingEventArgs e)
        {
            DataGridView oDgv = (DataGridView)sender;

            //==============================================
            if (oDgv != null && FormLoaded)
            {
                if (e.ColumnIndex == -1 + oDgv.Columns.Count)
                {
                    String CellValue = oDgv.CurrentRow.Cells[e.ColumnIndex].EditedFormattedValue.ToString();
                    if (String.IsNullOrEmpty(CellValue) || Convert.ToInt32(CellValue) == 0)
                    {
                        using (DialogCenteringService centeringService = new DialogCenteringService(this)) // center message box
                        {
                            MessageBox.Show("Please enter a value greater than 0", "Error", MessageBoxButtons.OK, MessageBoxIcon.Question);
                        }
                        e.Cancel = true;
                    }
                }
            }
        }
Пример #9
0
 private void Application_Idle(object sender, EventArgs e)
 {
     if (UpdateProgram.CanUpdate && !Runtime.DisableUpdatePrompt)
     {
         if (!UpdatePromptShown)
         {
             //Prompt once for the user to update the tool.
             UpdatePromptShown = true;
             DialogResult result;
             using (DialogCenteringService centeringService = new DialogCenteringService(this)) // center message box
             {
                 result = MessageBox.Show($"A new update is available {UpdateProgram.LatestRelease.TagName}!" +
                                          $" Would you like to install it?", "Updater", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1);
             }
             if (result == DialogResult.Yes)
             {
                 UpdateApplication();
             }
         }
     }
 }
Пример #10
0
        private void btnSubmit_Click(object sender, EventArgs e)
        {
            Button oBtn = (Button)sender;

            if (oBtn != null && FormLoaded)
            {
                if (QueryParms.Styles.Count == 0)
                {
                    using (DialogCenteringService svcs = new DialogCenteringService(this))
                    {
                        MessageBox.Show("Please select a style from the dropdown box");
                        return;
                    }
                }

                if (QueryParms.Colours.Count == 0)
                {
                    using (DialogCenteringService svcs = new DialogCenteringService(this))
                    {
                        MessageBox.Show("Please select a colour from the dropdown box");
                        return;
                    }
                }

                CSVServices csvService = new CSVServices();

                frmCSViewRep vRep = new frmCSViewRep(26, QueryParms, csvService);
                int          h    = Screen.PrimaryScreen.WorkingArea.Height;
                int          w    = Screen.PrimaryScreen.WorkingArea.Width;
                vRep.ClientSize = new Size(w, h);
                vRep.ShowDialog(this);

                cmboColours.Items.Clear();
                cmboStyles.Items.Clear();

                frmDaysSales_Load(this, null);
            }
        }
        private void PrincipalForm_FormClosing(object sender, FormClosingEventArgs e)
        {
            DialogResult dg;

            using (DialogCenteringService centeringService = new DialogCenteringService(this)) // center message box
            {
                dg = MessageBox.Show(this,
                                     "Tem certeza que deseja sair?",
                                     "Encerrar programa",
                                     MessageBoxButtons.YesNo, MessageBoxIcon.Question);
            }

            if (dg == DialogResult.No)
            {
                e.Cancel = true;
            }
            else
            {
                SegurancaForm f = Application.OpenForms["SegurancaForm"] as SegurancaForm;

                f.Close();
            }
        }
Пример #12
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;
                    }
                }
            }
        }
Пример #13
0
        private void btnRecalculate_Click(object sender, EventArgs e)
        {
            Button oBtn = (Button)sender;
            var    oDgv = (DataGridView)dataGridView1;

            if (oBtn != null && FormLoaded)
            {
                var RowCount = (from Rows in dataGridView1.Rows.Cast <DataGridViewRow>()
                                where (bool)Rows.Cells[1].Value == true
                                select Rows).Count();

                if (RowCount == 0)
                {
                    using (DialogCenteringService centeringService = new DialogCenteringService(this)) // center message box
                    {
                        MessageBox.Show("Please select at least one row to process");
                    }
                    return;
                }

                using (var context = new TTI2Entities())
                {
                    foreach (DataRow dr in dt.Rows)
                    {
                        if (!dr.Field <bool>(1))
                        {
                            continue;
                        }

                        var CurrentRow  = oDgv.CurrentRow;
                        var CurrentCell = oDgv.CurrentCell;
                        if (CurrentRow != null)
                        {
                            var CutSheetIndex = (int)CurrentRow.Cells[0].Value;
                            var CutSheet      = context.TLCUT_CutSheet.Find(CutSheetIndex);
                            if (CutSheet != null)
                            {
                                context.TLCUT_ExpectedUnits.Where(x => x.TLCUTE_CutSheet_FK == CutSheet.TLCutSH_Pk)
                                .Update(x => new TLCUT_ExpectedUnits()
                                {
                                    TLCUTE_EstNettWeight = 0, TLCUTE_NoOfBinding = 0, TLCUTE_NoofGarments = 0, TLCUTE_NoOfTrims = 0, TLCUTE_MarkerRatio = 0
                                });

                                var DBDetails = (from DBatch in context.TLDYE_DyeBatch
                                                 join DBatchDetails in context.TLDYE_DyeBatchDetails on DBatch.DYEB_Pk equals DBatchDetails.DYEBD_DyeBatch_FK
                                                 where DBatch.DYEB_Pk == CutSheet.TLCutSH_DyeBatch_FK
                                                 select DBatchDetails).ToList();

                                foreach (var dbd in DBDetails)
                                {
                                    if (dbd != null)
                                    {
                                        //Is a body or is it a Trim Record
                                        //===================================================
                                        if (dbd.DYEBD_BodyTrim)
                                        {
                                            //--------------------------------------------------------------
                                            // The aim of this event is to calculate the number of expected units
                                            // based on the nett weight of the piece of fabric selected
                                            // less the weight of the calculated binding needed (if applicable)
                                            //------------------------------------------------------------------
                                            var Yield = core.FabricYield(dbd.DYEBO_DiskWeight, dbd.DYEBO_Width);

                                            var NettWeight = dbd.DYEBO_Nett;
                                            var BindWeight = 0.00M;
                                            var TrimWeight = 0.00M;

                                            //---------------------------------------------------------
                                            // We now have to establish whether the style relating to the dye batch
                                            // has a Binding and if so what is the rating
                                            //----------------------------------------------------------------

                                            var StyleFK = (from DO in context.TLDYE_DyeOrder
                                                           join DB in context.TLDYE_DyeBatch on DO.TLDYO_Pk equals DB.DYEB_DyeOrder_FK
                                                           join DBD in context.TLDYE_DyeBatchDetails on DB.DYEB_Pk equals DBD.DYEBD_DyeBatch_FK
                                                           where DBD.DYEBD_Pk == dbd.DYEBD_Pk
                                                           select DO).FirstOrDefault().TLDYO_Style_FK;

                                            var ISBinding = (from stytrim in context.TLADM_StyleTrim
                                                             join trim in context.TLADM_Trims on stytrim.StyTrim_Trim_Fk equals trim.TR_Id
                                                             join prodrating in context.TLADM_ProductRating on stytrim.StyTrim_ProdRating_FK equals prodrating.Pr_Id
                                                             where stytrim.StyTrim_Styles_Fk == StyleFK && trim.TR_IsBinding
                                                             select prodrating).FirstOrDefault();

                                            if (ISBinding != null)
                                            {
                                                BindWeight  = NettWeight * ISBinding.Pr_numeric_Rating;
                                                NettWeight -= BindWeight;
                                            }

                                            var ISTrim = (from stytrim in context.TLADM_StyleTrim
                                                          join trim in context.TLADM_Trims on stytrim.StyTrim_Trim_Fk equals trim.TR_Id
                                                          join prodrating in context.TLADM_ProductRating on stytrim.StyTrim_ProdRating_FK equals prodrating.Pr_Id
                                                          where stytrim.StyTrim_Styles_Fk == StyleFK && !trim.TR_IsBinding
                                                          select prodrating).FirstOrDefault();

                                            if (ISTrim != null)
                                            {
                                                TrimWeight = dbd.DYEBO_Nett * ISTrim.Pr_numeric_Rating;
                                            }

                                            // select trims.TR_Description , pr.Pr_numeric_Rating
                                            // from TLADM_StyleTrim strim
                                            // inner join. TLADM_Trims trims
                                            // on trims.TR_Id = strim.StyTrim_Trim_Fk
                                            // inner join TLADM_ProductRating pr
                                            // on pr.Pr_Id = strim.StyTrim_ProdRating_FK
                                            // where trims.TR_IsBinding = 1 and strim.StyTrim_Styles_Fk = 34
                                            //-------------------------------------------------
                                            var ProdFK = dbd.DYEBO_ProductRating_FK;

                                            var Rating       = context.TLADM_ProductRating.Find(ProdFK).Pr_numeric_Rating;
                                            var NoOfGarments = Math.Round(Yield / Rating * NettWeight);

                                            var Factor = Math.Round(Yield / Rating * NettWeight, 0);
                                            var tst    = core.CalculateRatios(ProdFK, (int)Factor);

                                            foreach (var row in tst)
                                            {
                                                decimal EstKg  = Math.Round(NettWeight * (row.Value / Factor), 2);
                                                decimal BindKg = Math.Round(BindWeight * (row.Value / Factor), 2);
                                                decimal TrimKg = Math.Round(TrimWeight * (row.Value / Factor), 2);

                                                var ExpectUnits = context.TLCUT_ExpectedUnits.FirstOrDefault(x => x.TLCUTE_CutSheet_FK == CutSheet.TLCutSH_Pk && x.TLCUTE_Size_FK == row.Key);
                                                if (ExpectUnits != null)
                                                {
                                                    ExpectUnits.TLCUTE_EstNettWeight += EstKg;
                                                    ExpectUnits.TLCUTE_NoOfBinding   += (int)(Yield / Rating) * BindKg;
                                                    ExpectUnits.TLCUTE_NoOfTrims     += (int)(Yield / Rating) * TrimKg;
                                                    ExpectUnits.TLCUTE_NoofGarments  += (int)((Yield / Rating) * EstKg);
                                                    if (ExpectUnits.TLCUTE_MarkerRatio == 0.00M)
                                                    {
                                                        ExpectUnits.TLCUTE_MarkerRatio = row.Value;
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                            dr[1] = false;
                        }
                    }
                    try
                    {
                        context.SaveChanges();
                        MessageBox.Show("Data successfully saved to database");
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.InnerException.Message);
                    }
                }
            }
        }
Пример #14
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);
                    }
                }
            }
        }
Пример #15
0
        private void btnAccess_Click(object sender, EventArgs e)
        {
            Button oBtn = sender as Button;

            if (oBtn != null & formloaded)
            {
                using (var context = new TTI2Entities())
                {
                    if (ConfirmPassword)
                    {
                        String Password = txtUserPassword.Text.Replace('*', ' ');
                        if (Password.Length == 0)
                        {
                            using (DialogCenteringService centeringService = new DialogCenteringService(this)) // center message box
                            {
                                MessageBox.Show("Please enter a valid password");
                            }
                            return;
                        }
                        String Confirm = txtConfirmPassword.Text.Replace('*', ' ');
                        if (Confirm.Length == 0)
                        {
                            using (DialogCenteringService centeringService = new DialogCenteringService(this)) // center message box
                            {
                                MessageBox.Show("Please enter a validation password");
                            }
                            return;
                        }

                        IsAuthorised = String.Equals(Password.Trim(), Confirm.Trim(), StringComparison.CurrentCulture);
                        if (IsAuthorised)
                        {
                            var SelectedUser = (TLSEC_UserAccess)cmboUserDetails.SelectedItem;
                            if (SelectedUser != null)
                            {
                                var User = context.TLSEC_UserAccess.Where(x => x.TLSECUA_UserName == SelectedUser.TLSECUA_UserName).FirstOrDefault();
                                if (User != null)
                                {
                                    User.TLSECUA_ConfirmedPassword = true;
                                    User.TLSECUA_UserPassword      = Password;

                                    UserName    = User.TLSECUA_UserName;
                                    IsSuperUser = User.TLSECUA_SuperUser;
                                    UserPk      = User.TLSECUA_Pk;
                                    IsExternal  = User.TLSECUA_External;
                                    QAFunction  = User.TLSECUA_QAFunction;

                                    try
                                    {
                                        context.SaveChanges();
                                    }
                                    catch (Exception ex)
                                    {
                                        using (DialogCenteringService centeringService = new DialogCenteringService(this)) // center message box
                                        {
                                            MessageBox.Show(ex.Message);
                                        }
                                    }
                                }
                            }
                            this.Close();
                        }
                        else
                        {
                            using (DialogCenteringService centeringService = new DialogCenteringService(this)) // center message box
                            {
                                MessageBox.Show("Password not confirmed. Please reconfirm");
                            }
                            return;
                        }
                    }
                    else
                    {
                        var SelectedUser = (TLSEC_UserAccess)cmboUserDetails.SelectedItem;
                        if (SelectedUser != null)
                        {
                            var User = context.TLSEC_UserAccess.Where(x => x.TLSECUA_UserName == SelectedUser.TLSECUA_UserName).FirstOrDefault();
                            if (User != null)
                            {
                                String Password = txtUserPassword.Text.Replace('*', ' ');
                                String Confirm  = User.TLSECUA_UserPassword;

                                IsAuthorised = String.Equals(Password.Trim(), Confirm.Trim(), StringComparison.CurrentCulture);
                                if (IsAuthorised)
                                {
                                    UserName    = User.TLSECUA_UserName;
                                    IsSuperUser = User.TLSECUA_SuperUser;
                                    UserPk      = User.TLSECUA_Pk;
                                    IsExternal  = User.TLSECUA_External;

                                    this.Close();
                                }
                                else
                                {
                                    using (DialogCenteringService centeringService = new DialogCenteringService(this))  // center message box
                                    {
                                        MessageBox.Show("Please re-enter password", "Invalid Password for " + User.TLSECUA_UserName);
                                    }
                                    return;
                                }
                            }
                        }
                    }
                }
            }
        }
Пример #16
0
        private void btnSubmit_Click(object sender, EventArgs e)
        {
            Button            oBtn = sender as Button;
            Repository        repo = new Repository();
            TLCSV_BoxSelected boxSelected;

            if (oBtn != null && Submit)
            {
                var Depts = (TLADM_Departments)cmboFrom.SelectedItem;
                if (Depts == null)
                {
                    MessageBox.Show("Please select a CMT from from the drop down box");
                    return;
                }

                QueryParms.Depts.Add(repo.LoadDepart(Depts.Dep_Id));

                var BoxesAvailable = repo.Query(QueryParms);

                if (BoxesAvailable.Count() == 0)
                {
                    MessageBox.Show("There are no Boxes available");
                    return;
                }

                DGVResults.Rows.Clear();

                using (var context = new TTI2Entities())
                {
                    foreach (var Box in BoxesAvailable)
                    {
                        var index = DGVResults.Rows.Add();
                        DGVResults.Rows[index].Cells[0].Value = Box.TLCMTWC_Pk;
                        DGVResults.Rows[index].Cells[1].Value = false;
                        DGVResults.Rows[index].Cells[2].Value = Box.TLCMTWC_BoxNumber;
                        DGVResults.Rows[index].Cells[3].Value = Box.TLCMTWC_Qty;
                        DGVResults.Rows[index].Cells[4].Value = Box.TLCMTWC_Weight;
                        var Styles = context.TLADM_Styles.Find(Box.TLCMTWC_Style_FK);
                        if (Styles != null)
                        {
                            DGVResults.Rows[index].Cells[5].Value = context.TLADM_CustomerFile.Find(Styles.Sty_Label_FK).Cust_Description;
                            DGVResults.Rows[index].Cells[6].Value = Styles.Sty_Description;
                        }
                        DGVResults.Rows[index].Cells[7].Value = context.TLADM_Colours.Find(Box.TLCMTWC_Colour_FK).Col_Display;
                        DGVResults.Rows[index].Cells[8].Value = context.TLADM_Sizes.Find(Box.TLCMTWC_Size_FK).SI_Description;
                    }
                }


                DGVResults.Visible = true;

                label4.Visible = false;
                label5.Visible = false;
                label6.Visible = false;

                Submit         = !Submit;
                btnSubmit.Text = "Process";
                groupBox1.Text = "Results";
            }
            else
            {
                //-------------------------------------------------------------------
                // 1st Has a to destination been selected
                // If No return
                //------------------------------------------------------------------------
                var Dept = (TLADM_Departments)cmboFrom.SelectedItem;
                if (Dept == null)
                {
                    MessageBox.Show("Error encountered" + Environment.NewLine + "Process aborted");
                    return;
                }

                var Whse = (TLADM_WhseStore)cmboTo.SelectedItem;
                if (Whse == null)
                {
                    MessageBox.Show("Please select a TO Destination from the drop down box provided");
                    return;
                }

                var RecCount = DGVResults.Rows.Cast <DataGridViewRow>().Where(x => (bool)x.Cells[1].Value == true).Count();

                if (RecCount == 0)
                {
                    MessageBox.Show("Please select a least one record to process");
                    return;
                }

                using (var context = new TTI2Entities())
                {
                    //------------------------------------------------
                    // 1st Things first create a header record
                    //-------------------------------------------------------------------------

                    var LNU = context.TLADM_LastNumberUsed.Where(x => x.LUN_Department_FK == Dept.Dep_Id).FirstOrDefault();

                    boxSelected = new TLCSV_BoxSelected();

                    boxSelected.TLCSV_TransDate = dateTimePicker1.Value;
                    boxSelected.TLCSV_From_FK   = Dept.Dep_Id;
                    boxSelected.TLCSV_To_FK     = Whse.WhStore_Id;
                    if (LNU != null)
                    {
                        boxSelected.TLCSV_TransNumber = LNU.col6;
                        LNU.col6 += 1;
                    }

                    boxSelected.TLCSV_PLDetails = "CP" + boxSelected.TLCSV_TransNumber.ToString().PadLeft(5, '0');
                    try
                    {
                        context.TLCSV_BoxSelected.Add(boxSelected);
                        context.SaveChanges();
                    }
                    catch (Exception ex)
                    {
                        var exceptionMessages = new StringBuilder();
                        do
                        {
                            exceptionMessages.Append(ex.Message);
                            ex = ex.InnerException;
                        }while (ex != null);
                        MessageBox.Show(exceptionMessages.ToString());
                        return;
                    }

                    foreach (DataGridViewRow row in DGVResults.Rows)
                    {
                        if ((bool)row.Cells[1].Value == false)
                        {
                            continue;
                        }

                        TLCMT_CompletedWork comWork = new TLCMT_CompletedWork();
                        var index = (int)row.Cells[0].Value;
                        comWork = context.TLCMT_CompletedWork.Find(index);
                        if (comWork != null)
                        {
                            comWork.TLCMTWC_PickList_FK = boxSelected.TLCSV_Pk;
                            comWork.TLCMTWC_Picked      = true;
                            comWork.TLCMTWC_ToWhse_FK   = Whse.WhStore_Id;
                        }
                    }

                    try
                    {
                        context.SaveChanges();
                        using (DialogCenteringService centeringService = new DialogCenteringService(this)) // center message box
                        {
                            MessageBox.Show("Data successfully saved to the database");
                        }
                    }
                    catch (Exception ex)
                    {
                        var exceptionMessages = new StringBuilder();
                        do
                        {
                            exceptionMessages.Append(ex.Message);
                            ex = ex.InnerException;
                        }while (ex != null);
                        MessageBox.Show(exceptionMessages.ToString());
                        return;
                    }
                    //----------------------------------------------------------------------
                    frmCSViewRep vRep = new frmCSViewRep(1, boxSelected.TLCSV_Pk);
                    int          h    = Screen.PrimaryScreen.WorkingArea.Height;
                    int          w    = Screen.PrimaryScreen.WorkingArea.Width;
                    vRep.ClientSize = new Size(w, h);
                    vRep.ShowDialog(this);
                    //-----------------------------------------------------------------------

                    try
                    {
                        DialogResult res = MessageBox.Show(" Do you wish to send a confirmation email ", "Confirmation email", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                        if (res == DialogResult.Yes)
                        {
                            //-------------------------------------------------------------------
                            // We need to build up a data table of
                            // boxes( stock ) transfered
                            //-------------------------------------------------------------------
                            DataTable dt = new DataTable();
                            dt.Columns.Add("BoxNumber", typeof(String));
                            dt.Columns["BoxNumber"].DefaultValue = string.Empty;
                            dt.Columns.Add("Style", typeof(String));
                            dt.Columns["Style"].DefaultValue = string.Empty;
                            dt.Columns.Add("Colour", typeof(String));
                            dt.Columns["Colour"].DefaultValue = string.Empty;
                            dt.Columns.Add("Size", typeof(String));
                            dt.Columns["Size"].DefaultValue = string.Empty;
                            dt.Columns.Add("Grade", typeof(String));
                            dt.Columns["Grade"].DefaultValue = string.Empty;
                            dt.Columns.Add("Qty", typeof(int));
                            dt.Columns["Qty"].DefaultValue = 0;
                            dt.Columns.Add("Weight", typeof(decimal));
                            dt.Columns["Weight"].DefaultValue = 0.0M;

                            var BoxesTransfered = context.TLCMT_CompletedWork.Where(x => x.TLCMTWC_PickList_FK == boxSelected.TLCSV_Pk).ToList();
                            foreach (var Box in BoxesTransfered)
                            {
                                DataRow dr = dt.NewRow();
                                dr[0] = Box.TLCMTWC_BoxNumber;
                                dr[1] = context.TLADM_Styles.Find(Box.TLCMTWC_Style_FK).Sty_Description;
                                dr[2] = context.TLADM_Colours.Find(Box.TLCMTWC_Colour_FK).Col_Description;
                                dr[3] = context.TLADM_Sizes.Find(Box.TLCMTWC_Size_FK).SI_Description;
                                dr[4] = Box.TLCMTWC_Grade;
                                dr[5] = Box.TLCMTWC_Qty;
                                dr[6] = Box.TLCMTWC_Weight;
                                dt.Rows.Add(dr);
                            }

                            StringBuilder       EMailAdd     = new StringBuilder();
                            frmSeleEMailAddress EMailAddress = new frmSeleEMailAddress();
                            EMailAddress.ShowDialog(this);
                            var Email = EMailAddress.EMailSelected;
                            if (Email.ToString().Length > 0)
                            {
                                try
                                {
                                    string ToWhse = context.TLADM_WhseStore.Find(boxSelected.TLCSV_To_FK).WhStore_Description;

                                    core.SendEmailtoContacts(Email.ToString(), dt, 2, dateTimePicker1.Value, ToWhse, boxSelected.TLCSV_PLDetails);
                                    MessageBox.Show("Email successfully despatched");
                                }
                                catch (Exception ex)
                                {
                                    var exceptionMessages = new StringBuilder();
                                    do
                                    {
                                        exceptionMessages.Append(ex.Message);
                                        ex = ex.InnerException;
                                    }while (ex != null);
                                    MessageBox.Show(exceptionMessages.ToString());
                                }
                            }
                            else
                            {
                                MessageBox.Show("No Email address's selected or Email address's do not exist");
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        var exceptionMessages = new StringBuilder();
                        do
                        {
                            exceptionMessages.Append(ex.Message);
                            ex = ex.InnerException;
                        }while (ex != null);
                        MessageBox.Show(exceptionMessages.ToString());
                    }
                }



                DGVResults.Visible = false;

                groupBox1.Text = "Selection";

                label4.Visible = true;
                label5.Visible = true;
                label6.Visible = true;

                Submit         = !Submit;
                btnSubmit.Text = "Submit";

                cmboStyles.Items.Clear();
                cmboColours.Items.Clear();
                cmboSizes.Items.Clear();

                frmWareHouseTransfers_Load(this, null);
            }
        }
Пример #17
0
        private void datagridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            Util       core = new Util();
            var        oDgv = sender as DataGridView;
            int        pn   = 0;
            List <int> xx   = null;

            if (oDgv.Focused && oDgv.CurrentCell is DataGridViewButtonCell)
            {
                if (e.ColumnIndex == 1)
                {
                    if (rbBody.Checked)
                    {
                        var Id = 1005;

                        var RowPos = oDgv.CurrentRow.Index;
                        pn = int.Parse(oDgv.CurrentRow.Cells[9].Value.ToString());
                        frmTLADMGardProp aprop = new frmTLADMGardProp(Id, pn, Listsizes);
                        aprop.ShowDialog();
                        var sizes = aprop.TotalPN;
                        if (sizes != 0)
                        {
                            StringBuilder desciption = new StringBuilder();
                            int           a          = Convert.ToInt32(sizes);
                            using (var context = new TTI2Entities())
                            {
                                xx = core.ExtrapNumber(a, context.TLADM_Sizes.Count());
                            }
                            xx.Sort();

                            oDgv.CurrentRow.Cells[8].Value = false;
                            if (xx.Count > 1)
                            {
                                oDgv.CurrentRow.Cells[8].Value = true;
                            }

                            foreach (var rw in xx)
                            {
                                bool First = true;
                                foreach (var dd in Listsizes)
                                {
                                    if (dd.SI_PowerN == rw)
                                    {
                                        if (First)
                                        {
                                            First = !First;
                                            oDgv.CurrentRow.Cells[11].Value = dd.SI_id;
                                        }
                                        if (desciption.Length == 0)
                                        {
                                            desciption.Append(dd.SI_Description);
                                        }
                                        else
                                        {
                                            desciption.Append(", " + dd.SI_Description);
                                        }
                                    }
                                }
                            }

                            oDgv.CurrentRow.Cells[10].Value = false;
                            if ((int)oDgv.CurrentRow.Cells[0].Value == 0)
                            {
                                oDgv.CurrentRow.Cells[10].Value = true;
                            }

                            oDgv.CurrentRow.Cells[1].Value = desciption;
                            oDgv.CurrentRow.Cells[7].Value = "Ratio";
                            oDgv.CurrentRow.Cells[9].Value = sizes;
                        }
                    }
                    else if (rbTrims.Checked)
                    {
                        var StyleSelected = (TLADM_Styles)cmbStyles.SelectedItem;
                        if (StyleSelected != null)
                        {
                            var   Id       = 1007;
                            int[] TrimKeys = new int[2];
                            // First Element is the style
                            //======================================
                            TrimKeys[0] = StyleSelected.Sty_Id;
                            // Second element is the Primary Key of the Trim
                            //===============================================
                            TrimKeys[1] = (int)oDgv.Rows[e.RowIndex].Cells[11].Value;

                            var RowPos = oDgv.CurrentRow.Index;
                            pn = int.Parse(oDgv.CurrentRow.Cells[9].Value.ToString());
                            frmTLADMGardProp aprop = new frmTLADMGardProp(Id, TrimKeys, true);
                            aprop.ShowDialog();
                            var sizes = aprop._TrimKeys;
                            oDgv.CurrentRow.Cells[8].Value = false;

                            oDgv.CurrentRow.Cells[10].Value = false;
                            if ((int)oDgv.CurrentRow.Cells[0].Value == 0)
                            {
                                oDgv.CurrentRow.Cells[10].Value = true;
                            }

                            oDgv.CurrentRow.Cells[11].Value = sizes[1];
                            using (var context = new TTI2Entities())
                            {
                                oDgv.CurrentRow.Cells[1].Value = context.TLADM_Trims.Find(sizes[1]).TR_Description;
                            }

                            oDgv.CurrentRow.Cells[7].Value = "Ratio";
                            oDgv.CurrentRow.Cells[9].Value = 0;
                        }
                    }
                }
                else
                {
                    // Only available to body details
                    //-----------------------------------------------
                    if (!rbBody.Checked)
                    {
                        using (DialogCenteringService centeringService = new DialogCenteringService(this)) // center message box
                        {
                            MessageBox.Show("Please select the body check box prior to selecting this option");
                        }
                        return;
                    }

                    //Only available to multi sized markers
                    //-----------------------------------------------
                    var CurrentRow = oDgv.CurrentRow;

                    if (!(bool)CurrentRow.Cells[8].Value)
                    {
                        using (DialogCenteringService centeringService = new DialogCenteringService(this))  // center message box
                        {
                            MessageBox.Show("This option is only available to multi sized Markers");
                            return;
                        }
                    }
                    else
                    {
                        var PNumber    = (int)CurrentRow.Cells[9].Value;
                        int PrimaryKey = (int)CurrentRow.Cells[0].Value;

                        if (PrimaryKey == 0)
                        {
                            using (var context = new TTI2Entities())
                            {
                                TLADM_ProductRating ProductRating = new TLADM_ProductRating();
                                context.TLADM_ProductRating.Add(ProductRating);

                                try
                                {
                                    context.SaveChanges();
                                    PrimaryKey = ProductRating.Pr_Id;
                                    CurrentRow.Cells[0].Value  = PrimaryKey;
                                    CurrentRow.Cells[10].Value = false;
                                }
                                catch (Exception ex)
                                {
                                    MessageBox.Show(ex.InnerException.Message.ToString());
                                    return;
                                }
                            }
                        }


                        frmTLADMProductRatingDetail prodDetail = new frmTLADMProductRatingDetail(PNumber, PrimaryKey);
                        prodDetail.ShowDialog(this);
                        if (prodDetail.ProductRatio != 0)
                        {
                            oDgv.Rows[e.RowIndex].Cells[4].Value = (decimal)prodDetail.ProductRatio;
                            if (oDgv.Rows[e.RowIndex].Cells[5].Value != null)
                            {
                                var ML = (decimal)oDgv.Rows[e.RowIndex].Cells[5].Value;
                                try
                                {
                                    oDgv.Rows[e.RowIndex].Cells[6].Value = Math.Round(ML / prodDetail.ProductRatio, 4);
                                }
                                catch (Exception ex)
                                {
                                    MessageBox.Show(ex.Message);
                                    return;
                                }
                            }
                        }
                    }
                }
            }
        }
Пример #18
0
        private void rbRejectStore_CheckedChanged(object sender, EventArgs e)
        {
            RadioButton oRad = sender as RadioButton;

            if (oRad != null && formloaded && oRad.Checked)
            {
                var GreigeSelected = (TLADM_Griege)cmboGreige.SelectedItem;
                if (GreigeSelected != null)
                {
                    using (var context = new TTI2Entities())
                    {
                        dataGridView1.Rows.Clear();

                        var dbDetails = (from GP in context.TLKNI_GreigeProduction
                                         join DBD in context.TLDYE_DyeBatchDetails
                                         on GP.GreigeP_Pk equals DBD.DYEBD_GreigeProduction_FK
                                         join ADMGriege in context.TLADM_Griege
                                         on GP.GreigeP_Greige_Fk equals ADMGriege.TLGreige_Id
                                         where !GP.GreigeP_BoughtIn &&
                                         !DBD.DYEBO_QAApproved &&
                                         DBD.DYEBO_Rejected &&
                                         !DBD.DYEBO_WriteOff &&
                                         !DBD.DYEBO_Sold &&
                                         !DBD.DYEBO_CutSheet &&
                                         DBD.DYEBD_QualityKey == GreigeSelected.TLGreige_Id
                                         orderby GP.GreigeP_PieceNo
                                         select new { DBD, GP, ADMGriege }).ToList();


                        if (dbDetails.Count == 0)
                        {
                            using (DialogCenteringService centeringService = new DialogCenteringService(this)) // center message box
                            {
                                MessageBox.Show("There are no records found pertaining to selection made", "No Records Found", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                return;
                            }
                        }

                        foreach (var row in dbDetails)
                        {
                            var index = dataGridView1.Rows.Add();
                            dataGridView1.Rows[index].Cells[0].Value = row.DBD.DYEBD_Pk;
                            dataGridView1.Rows[index].Cells[1].Value = row.GP.GreigeP_PieceNo;
                            dataGridView1.Rows[index].Cells[2].Value = row.ADMGriege.TLGreige_Description;
                            var BD = context.TLDYE_DyeBatch.Find(row.DBD.DYEBD_DyeBatch_FK);
                            if (BD != null)
                            {
                                dataGridView1.Rows[index].Cells[3].Value = context.TLADM_Colours.Find(BD.DYEB_Colour_FK).Col_Display;
                            }
                            dataGridView1.Rows[index].Cells[4].Value = row.DBD.DYEBD_GreigeProduction_Weight;
                            dataGridView1.Rows[index].Cells[5].Value = row.DBD.DYEBO_Nett;
                            dataGridView1.Rows[index].Cells[6].Value = row.DBD.DYEBO_DiskWeight;

                            dataGridView1.Rows[index].Cells[7].Value = 0;
                            dataGridView1.Rows[index].Cells[8].Value = 0;
                            dataGridView1.Rows[index].Cells[9].Value = 0;

                            dataGridView1.Rows[index].Cells[10].Value = false;
                            dataGridView1.Rows[index].Cells[11].Value = row.DBD.DYEBD_DyeBatch_FK;
                        }
                    }
                }
                else
                {
                    using (DialogCenteringService centeringService = new DialogCenteringService(this)) // center message box
                    {
                        MessageBox.Show("Please select a quality from the drop down box");
                    }
                }
            }
        }