Exemple #1
0
        public frmGreigeProduction(TLKNI_Order KO)
        {
            InitializeComponent();
            core = new Util();
            txtKnitOrderWeight.KeyDown  += core.txtWin_KeyDownOEM;
            txtKnitOrderWeight.KeyPress += core.txtWin_KeyPress;
            txtKOPieces.KeyDown         += core.txtWin_KeyDown;
            txtKOPieces.KeyPress        += core.txtWin_KeyPress;

            _KO = KO;

            SetUp();
        }
Exemple #2
0
        private void frmKnitOrderAdjust_Load(object sender, EventArgs e)
        {
            FormLoaded = false;

            using (var context = new TTI2Entities())
            {
                comboGreige.DataSource    = context.TLADM_Griege.OrderBy(x => x.TLGreige_Description).ToList();
                comboGreige.ValueMember   = "TLGreige_Id";
                comboGreige.DisplayMember = "TLGreige_Description";
                comboGreige.SelectedValue = -1;

                var Department = context.TLADM_Departments.Where(x => x.Dep_ShortCode.Contains("KNIT")).FirstOrDefault();
                if (Department != null)
                {
                    comboMachine.DataSource    = context.TLADM_MachineDefinitions.Where(x => x.MD_Department_FK == Department.Dep_Id).OrderBy(x => x.MD_AlternateDesc).ToList();
                    comboMachine.DisplayMember = "MD_AlternateDesc";
                    comboMachine.ValueMember   = "MD_Pk";
                    comboMachine.SelectedValue = -1;

                    KnitO = context.TLKNI_Order.Find(_KnitOrderPk);

                    if (KnitO != null)
                    {
                        cbResetYarnAllocated.Checked = false;

                        if (KnitO.KnitO_Closed)
                        {
                            rbClosed.Checked = true;
                        }
                        else
                        {
                            rbActive.Checked = true;
                        }

                        label5.Text = KnitO.KnitO_OrderNumber.ToString();
                        comboGreige.SelectedValue = KnitO.KnitO_Product_FK;
                        label4.Text = KnitO.KnitO_NoOfPieces.ToString();

                        comboMachine.SelectedValue = KnitO.KnitO_Machine_FK;
                    }
                }
            }

            FormLoaded = true;
        }
        private void btnSave_Click(object sender, EventArgs e)
        {
            Button      oBtn = sender as Button;
            TLKNI_Order KO   = null;

            if (oBtn != null && formloaded)
            {
                if (Decimal.Parse(txtAdjustedWeight.Text) > 0)
                {
                    Decimal Weight = Decimal.Parse(txtAdjustedWeight.Text);
                    if (GreigeProd.GreigeP_weight - Weight >= 0)
                    {
                        using (var context = new TTI2Entities())
                        {
                            var GP = context.TLKNI_GreigeProduction.Find(GreigeProd.GreigeP_Pk);
                            if (GP != null)
                            {
                                if (GP.GreigeP_KnitO_Fk != null)
                                {
                                    KO = context.TLKNI_Order.Find(GP.GreigeP_KnitO_Fk);
                                    if (KO != null)
                                    {
                                        //============================================
                                        // Create an actual Production split record
                                        //=============================================
                                        TLKNI_ProductionSplit ProdSplit = new TLKNI_ProductionSplit();
                                        ProdSplit.TLKNISP_FromStore_FK = (int)GreigeProd.GreigeP_Store_FK;
                                        if (radKNumber.Checked)
                                        {
                                            ProdSplit.TLKNISP_NewPieceNo = "K" + GreigeProd.GreigeP_PieceNo.ToString();
                                        }
                                        else
                                        {
                                            ProdSplit.TLKNISP_NewPieceNo = "R" + GreigeProd.GreigeP_PieceNo.ToString();
                                        }

                                        ProdSplit.TLKNISP_Date         = DateTime.Now;
                                        ProdSplit.TLKNISP_OrigPieceNo  = GreigeProd.GreigeP_PieceNo;
                                        ProdSplit.TLKNISP_Notes        = txtReasons.Text;
                                        ProdSplit.TLKNISP_Mass         = GP.GreigeP_weight - Weight;
                                        ProdSplit.TLKNISP_KnitOrder_FK = KO.KnitO_Pk;
                                        var Dept = context.TLADM_Departments.Where(x => x.Dep_ShortCode.Contains("KNIT")).FirstOrDefault();
                                        if (Dept != null)
                                        {
                                            var TranType = context.TLADM_TranactionType.Where(x => x.TrxT_Department_FK == Dept.Dep_Id && x.TrxT_Number == 2005).FirstOrDefault();
                                            if (TranType != null)
                                            {
                                                ProdSplit.TLKNISP_ToStore_FK = (int)TranType.TrxT_ToWhse_FK;
                                            }
                                        }

                                        context.TLKNI_ProductionSplit.Add(ProdSplit);

                                        //================================================
                                        // Now Adjust the actual GP record with new weight
                                        //=========================================
                                        GP.GreigeP_weight      = Weight;
                                        GP.GreigeP_weightAvail = Weight;
                                    }
                                }
                            }
                            try
                            {
                                context.SaveChanges();
                                MessageBox.Show("Data successfully saved to database");
                                this.Close();
                            }
                            catch (Exception ex)
                            {
                                MessageBox.Show(ex.Message);
                            }
                        }
                    }
                    else
                    {
                        MessageBox.Show("Cannot split more than what was originally Knitted");
                    }
                }
            }
        }
Exemple #4
0
        private void cbResetYarnAllocated_CheckedChanged(object sender, EventArgs e)
        {
            CheckBox oChk = sender as CheckBox;

            if (oChk != null && FormLoaded)
            {
                if (oChk.Checked)
                {
                    DialogResult res = MessageBox.Show("Please confirm this transaction", "Confimation Required", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                    if (res == DialogResult.Yes)
                    {
                        using (var context = new TTI2Entities())
                        {
                            if (KnitO == null)
                            {
                                KnitO = context.TLKNI_Order.Find(_KnitOrderPk);
                            }

                            if (KnitO != null && KnitO.KnitO_YarnAssigned)
                            {
                                KnitO.KnitO_YarnAssigned = false;

                                var YarnAllocs = context.TLKNI_YarnAllocTransctions.Where(x => x.TLKYT_KnitOrder_FK == KnitO.KnitO_Pk).ToList();
                                foreach (var YarnAlloc in YarnAllocs)
                                {
                                    var YarnPallet = context.TLKNI_YarnOrderPallets.Find(YarnAlloc.TLKYT_YOP_FK);
                                    if (YarnPallet != null)
                                    {
                                        YarnPallet.TLKNIOP_ReservedBy         = 0;
                                        YarnPallet.TLKNIOP_NettWeightReserved = 0;
                                        YarnPallet.TLKNIOP_ConesReserved      = 0;
                                        YarnPallet.TLKNIOP_ReservedDate       = null;
                                        YarnPallet.TLKNIOP_AdditionalYarn     = 0;
                                        YarnPallet.TLKNIOP_NettWeightReturned = 0;
                                    }
                                }

                                context.TLKNI_YarnAllocTransctions.RemoveRange(context.TLKNI_YarnAllocTransctions.Where(x => x.TLKYT_KnitOrder_FK == KnitO.KnitO_Pk));

                                try
                                {
                                    context.SaveChanges();
                                    MessageBox.Show("Data successfully saved to database");
                                    return;
                                }
                                catch (System.Data.Entity.Validation.DbEntityValidationException en)
                                {
                                    foreach (var eve in en.EntityValidationErrors)
                                    {
                                        MessageBox.Show("following validation errors: Type" + eve.Entry.Entity.GetType().Name.ToString() + "State " + eve.Entry.State.ToString());
                                        foreach (var ve in eve.ValidationErrors)
                                        {
                                            MessageBox.Show("- Property" + ve.PropertyName + " Message " + ve.ErrorMessage);
                                        }
                                    }
                                }
                                catch (Exception ex)
                                {
                                    MessageBox.Show(ex.Message);
                                }
                            }
                            else
                            {
                                MessageBox.Show("Unable to action request. No yarn currently assigned");
                            }
                        }
                    }
                }
            }
        }