Exemple #1
0
        private void But_PNCRevision_Click(object sender, EventArgs e)
        {
            Cursor.Current = Cursors.WaitCursor;
            var Option = MainProgram.Self.adminTableView.optionsView;
            var Table  = MainProgram.Self.adminTableView.ReturnDataGridView();

            if (Option.GetMonth() != 0 && Option.GetRevision() != "")
            {
                Table.DataSource = PNCRevisionQuantity.LoadByYear_Month_Revision(
                    Convert.ToInt32(Option.GetYear()),
                    Convert.ToInt32(Option.GetMonth()),
                    Option.GetRevision()
                    );
            }
            else if (Option.GetMonth() != 0)
            {
                Table.DataSource = PNCRevisionQuantity.LoadByYear_Month(
                    Convert.ToInt32(Option.GetYear()),
                    Convert.ToInt32(Option.GetMonth())
                    );
            }
            else if (Option.GetRevision() != "")
            {
                Table.DataSource = PNCRevisionQuantity.LoadByYear_Revision(
                    Convert.ToInt32(Option.GetYear()),
                    Option.GetRevision()
                    );
            }
            else
            {
                Table.DataSource = PNCRevisionQuantity.LoadByYear(
                    Convert.ToInt32(Option.GetYear()));
            }

            Cursor.Current = Cursors.Default;
        }
Exemple #2
0
        public PNCRevisionQuantityAdd(string Revision, int AddYear, string[] DataToAdd)
        {
            var PNCList    = PNCRevisionQuantity.LoadByYear_Revision(AddYear, Revision);
            int StartMonth = 0;

            if (Revision == "BU")
            {
                StartMonth = 1;
            }
            else if (Revision == "EA1")
            {
                StartMonth = 3;
            }
            else if (Revision == "EA2")
            {
                StartMonth = 6;
            }
            else if (Revision == "EA3")
            {
                StartMonth = 9;
            }

            if (StartMonth == 0)
            {
                return;
            }

            if (PNCList != null)
            {
                PNCRevisionQuantity.RemoveList(PNCList);
            }
            List <PNCRevisionDB> ListPNC = new List <PNCRevisionDB>();


            foreach (string Data in DataToAdd)
            {
                string[] AddData = Data.Split('\t');
                if (AddData.Length != 1)
                {
                    int StringCount = 1;

                    for (int counter = StartMonth; counter < 13; counter++)
                    {
                        var NewRow = new PNCRevisionDB
                        {
                            PNC      = AddData[0].ToString(),
                            Year     = AddYear,
                            Month    = counter,
                            Revision = Revision,
                            Value    = Convert.ToDouble(AddData[StringCount]),
                        };
                        StringCount++;
                        ListPNC.Add(NewRow);
                    }
                }
            }

            if (ListPNC != null)
            {
                PNCRevisionQuantity.AddList(ListPNC);
            }
        }
Exemple #3
0
        public GroupPNCRevision(int Year, string Revision)
        {
            IEnumerable <PNCRevisionDB>         AllQuantity = PNCRevisionQuantity.LoadByYear_Revision(Year, Revision);
            IEnumerable <SumRevisionQuantityDB> SumQuantity = SumRevisionController.LoadByRervision(Year, Revision);
            List <SumRevisionQuantityDB>        SumToAdd    = new List <SumRevisionQuantityDB>();

            if (AllQuantity.Count() == 0)
            {
                MessageBox.Show("No Data To Sum!");
                return;
            }

            if (SumQuantity.Count() != 0)
            {
                SumRevisionController.RemoveData(SumQuantity);
            }

            for (int Month = StartMonth(Revision); Month <= 12; Month++)
            {
                double DMD_FS   = 0;
                double DMD_FI   = 0;
                double DMD_BI   = 0;
                double DMD_FSBU = 0;
                double D45_FS   = 0;
                double D45_FI   = 0;
                double D45_BI   = 0;
                double D45_FSBU = 0;

                IEnumerable <PNCRevisionDB> AllQuantityMonth = AllQuantity.Where(u => u.Month == Month).ToList();

                foreach (PNCRevisionDB PNC in AllQuantityMonth)
                {
                    if (PNC.PNC.Remove(0, 3).Remove(1, 5) == "5")
                    {
                        switch (PNC.PNC.Remove(0, 4).Remove(1, 4))
                        {
                        case "1":
                            DMD_FS += PNC.Value;
                            break;

                        case "2":
                            DMD_BI += PNC.Value;
                            break;

                        case "3":
                            DMD_FI += PNC.Value;
                            break;

                        case "4":
                            DMD_FSBU += PNC.Value;
                            break;

                        default:
                            break;
                        }
                    }
                    else if (PNC.PNC.Remove(0, 3).Remove(1, 5) == "0")
                    {
                        switch (PNC.PNC.Remove(0, 4).Remove(1, 4))
                        {
                        case "5":
                            D45_FS += PNC.Value;
                            break;

                        case "6":
                            D45_BI += PNC.Value;
                            break;

                        case "7":
                            D45_FI += PNC.Value;
                            break;

                        case "8":
                            D45_FSBU += PNC.Value;
                            break;

                        default:
                            break;
                        }
                    }
                }

                var DMDFS = new SumRevisionQuantityDB
                {
                    Platform     = "DMD",
                    Installation = "FS",
                    Revision     = Revision,
                    Year         = Year,
                    Month        = Month,
                    Value        = DMD_FS,
                };
                var DMDFI = new SumRevisionQuantityDB
                {
                    Platform     = "DMD",
                    Installation = "FI",
                    Revision     = Revision,
                    Year         = Year,
                    Month        = Month,
                    Value        = DMD_FI,
                };
                var DMDBI = new SumRevisionQuantityDB
                {
                    Platform     = "DMD",
                    Installation = "BI",
                    Revision     = Revision,
                    Year         = Year,
                    Month        = Month,
                    Value        = DMD_BI,
                };
                var DMDFSBU = new SumRevisionQuantityDB
                {
                    Platform     = "DMD",
                    Installation = "FSBU",
                    Revision     = Revision,
                    Year         = Year,
                    Month        = Month,
                    Value        = DMD_FSBU,
                };
                var D45FS = new SumRevisionQuantityDB
                {
                    Platform     = "D45",
                    Installation = "FS",
                    Revision     = Revision,
                    Year         = Year,
                    Month        = Month,
                    Value        = D45_FS,
                };
                var D45FI = new SumRevisionQuantityDB
                {
                    Platform     = "D45",
                    Installation = "FI",
                    Revision     = Revision,
                    Year         = Year,
                    Month        = Month,
                    Value        = D45_FI,
                };
                var D45BI = new SumRevisionQuantityDB
                {
                    Platform     = "D45",
                    Installation = "BI",
                    Revision     = Revision,
                    Year         = Year,
                    Month        = Month,
                    Value        = D45_BI,
                };
                var D45FSBU = new SumRevisionQuantityDB
                {
                    Platform     = "D45",
                    Installation = "FSBU",
                    Revision     = Revision,
                    Year         = Year,
                    Month        = Month,
                    Value        = D45_FSBU,
                };

                SumToAdd.Add(DMDFS);
                SumToAdd.Add(DMDFI);
                SumToAdd.Add(DMDBI);
                SumToAdd.Add(DMDFSBU);
                SumToAdd.Add(D45FS);
                SumToAdd.Add(D45FI);
                SumToAdd.Add(D45BI);
                SumToAdd.Add(D45FSBU);
            }

            if (SumToAdd.Count() != 0)
            {
                SumRevisionController.AddData(SumToAdd);
            }
        }