예제 #1
0
        private void btnDept_Click(object sender, EventArgs e)
        {
            Button oBtn = sender as Button;

            if (oBtn != null)
            {
                frmTLADMGardProp depts = new frmTLADMGardProp(5000, Convert.ToInt32(oBtn.Text));
                depts.ShowDialog(this);
                oBtn.Text = depts.TotalPN.ToString();
            }
        }
예제 #2
0
        private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            int          pn   = 0;
            DataGridView oDgv = sender as DataGridView;

            if (oDgv.Focused && oDgv.CurrentCell is DataGridViewButtonCell)
            {
                var Id = 1000 + e.ColumnIndex;

                if (!String.IsNullOrEmpty(oDgv.CurrentCell.EditedFormattedValue.ToString()))
                {
                    pn = Convert.ToInt32(oDgv.CurrentCell.EditedFormattedValue.ToString());
                }
                frmTLADMGardProp aprop = new frmTLADMGardProp(Id, pn);
                aprop.ShowDialog();
                oDgv.CurrentCell.Value = aprop.TotalPN.ToString();
            }
        }
예제 #3
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;
                                }
                            }
                        }
                    }
                }
            }
        }