コード例 #1
0
ファイル: ManualUpdateSTK.cs プロジェクト: bartkkon/SAT
        public ManualUpdateSTK(string[] STKData, int Year)
        {
            List <STKDB> NewSTKManual = new List <STKDB>();

            foreach (string OneRow in STKData)
            {
                string[] ToAdd = OneRow.Split('\t');

                if (ToAdd.Length != 1 && ToAdd.Length == 4)
                {
                    var NewRow = new STKDB
                    {
                        ANC         = ToAdd[0],
                        Description = ToAdd[1],
                        IDCO        = ToAdd[2],
                        Year        = Year,
                        Month       = 0,
                        Day         = 0,
                        Value       = Convert.ToDouble(ToAdd[3]),
                    };
                    NewSTKManual.Add(NewRow);
                }
            }

            if (NewSTKManual != null)
            {
                STKController.AddManualUpdate(NewSTKManual);
            }
        }
コード例 #2
0
        private void But_STK_Click(object sender, EventArgs e)
        {
            Cursor.Current = Cursors.WaitCursor;
            var Option = MainProgram.Self.adminTableView.optionsView;
            var Table  = MainProgram.Self.adminTableView.ReturnDataGridView();

            Table.DataSource = STKController.Load_By_Year(Convert.ToInt32(Option.GetYear()));

            Cursor.Current = Cursors.Default;
        }
コード例 #3
0
ファイル: FindSTK.cs プロジェクト: bartkkon/SAT
        public FindSTK(int Count, string NewOld, string ANC, double Quantity)
        {
            Cursor.Current = Cursors.WaitCursor;

            if (ANC == "n/a" || ANC == string.Empty)
            {
                if (NewOld == "New")
                {
                    MainProgram.Self.actionView.StkChange.SetNewSTK(Count, ANC);
                }
                else if (NewOld == "Old")
                {
                    MainProgram.Self.actionView.StkChange.SetOldSTK(Count, ANC);
                }
            }
            else
            {
                decimal ActionYear = MainProgram.Self.actionView.stateView.GetYear();

                var ANCSTK = STKController.Load(Convert.ToInt32(ActionYear), ANC);

                if (ANCSTK == null)
                {
                    if (NewOld == "New")
                    {
                        MainProgram.Self.actionView.StkChange.SetNewSTK(Count, "n/a");
                    }
                    else if (NewOld == "Old")
                    {
                        MainProgram.Self.actionView.StkChange.SetOldSTK(Count, "n/a");
                    }
                }
                else
                {
                    if (NewOld == "New")
                    {
                        double Suma = ANCSTK.Value * Quantity;
                        Suma = Math.Round(Suma, 4, MidpointRounding.AwayFromZero);
                        MainProgram.Self.actionView.StkChange.SetNewSTK(Count, Suma.ToString());
                        MainProgram.Self.actionView.ANCChangeView.SetNewIDCO(Count, ANCSTK.IDCO);
                    }
                    else if (NewOld == "Old")
                    {
                        double Suma = ANCSTK.Value * Quantity;
                        Suma = Math.Round(Suma, 4, MidpointRounding.AwayFromZero);
                        MainProgram.Self.actionView.StkChange.SetOldSTK(Count, Suma.ToString());
                        MainProgram.Self.actionView.ANCChangeView.SetOldIDCO(Count, ANCSTK.IDCO);
                    }
                }
            }

            Cursor.Current = Cursors.Default;
        }
コード例 #4
0
ファイル: STKUpdate.cs プロジェクト: bartkkon/SAT
        public STKUpdate_ManualUpdate(int Year)
        {
            var List = STKController.Load_By_Year(Year);

            if (List != null)
            {
                DialogResult Results = MessageBox.Show("Dane STK na rok " + Year.ToString() + " istnieją!. Czy zamienić je ?", "Uwaga", MessageBoxButtons.YesNo);
                if (Results == DialogResult.Yes)
                {
                    STKController.Remove_Year(Year);
                }
                else
                {
                    return;
                }
            }

            _ = new AddData("Wprowadz dane STK dla Manualanego zaktualizowania", Year);
        }
コード例 #5
0
ファイル: STKUpdate.cs プロジェクト: bartkkon/SAT
 public STKUpdateRemove(int Year)
 {
     STKController.Remove_Year(Year);
 }
コード例 #6
0
ファイル: STKUpdate.cs プロジェクト: bartkkon/SAT
        public STKUpdate()
        {
            string FileName;

            string[] STKFile;
            int      Add    = 0;
            int      Update = 0;

            FileName = FindLink();

            if (FileName == string.Empty)
            {
                MessageBox.Show("Brak pliku z STK od 10 dni lub w tym roku");
                return;
            }

            var STKDataBase = STKController.Load_By_Year(DateTime.UtcNow.Year);

            STKFile = File.ReadAllLines(FileName);

            foreach (string OneLine in STKFile)
            {
                string ANC;
                int    Year;
                int    Month;
                int    Day;
                double STK;
                string Name;
                string IDCO;

                string line_help = OneLine;

                line_help = line_help.Remove(0, 2);
                ANC       = line_help.Remove(9);
                line_help = line_help.Remove(0, 11);
                Year      = 2000 + Convert.ToInt32(line_help.Remove(2));
                line_help = line_help.Remove(0, 2);
                Month     = Convert.ToInt32(line_help.Remove(2));
                line_help = line_help.Remove(0, 2);
                Day       = Convert.ToInt32(line_help.Remove(2));
                line_help = line_help.Remove(0, 2);
                STK       = Convert.ToDouble(line_help.Remove(9)) / 10000;
                line_help = line_help.Remove(0, 154);
                Name      = line_help.Remove(30).Trim();
                line_help = line_help.Remove(0, 31);
                IDCO      = line_help.Remove(4);

                if (Skip(Name))
                {
                    STKDB Find = STKDataBase.Where(u => u.ANC == ANC).FirstOrDefault();

                    if (Find == null)
                    {
                        var NewRow = new STKDB
                        {
                            ANC         = ANC,
                            Description = Name,
                            IDCO        = IDCO,
                            Day         = Day,
                            Month       = Month,
                            Year        = Year,
                            Value       = STK,
                        };
                        STKController.AddNewValue(NewRow);
                        Add++;
                    }
                    else
                    {
                        if (STK != Find.Value)
                        {
                            Find.Description = Name;
                            Find.IDCO        = IDCO;
                            Find.Day         = Day;
                            Find.Month       = Month;
                            Find.Year        = Year;
                            Find.Value       = STK;
                            STKController.UpdateValue(Find);
                            Update++;
                        }
                    }
                }
            }
            MessageBox.Show("Dodano: " + Add.ToString() + Environment.NewLine + "Zaktualizwoano: " + Update.ToString());
        }
コード例 #7
0
        public static bool Find(DataTable PNCList)
        {
            DataRow PNCRow;
            decimal Year;

            STKList = new List <STKDB>();
            PNCRow  = PNCList.NewRow();

            Year = MainProgram.Self.actionView.stateView.GetYear();

            foreach (DataRow Row in PNCList.Rows)
            {
                if (Row["PNC"].ToString() != string.Empty)
                {
                    PNCRow = Row;
                }
                else
                {
                    if (Row["OLD ANC"].ToString() != string.Empty)
                    {
                        if (!STKList.Any(x => x.ANC == Row["OLD ANC"].ToString()))
                        {
                            STKDB FindSTK = STKController.Load(Convert.ToInt32(Year), Row["OLD ANC"].ToString());
                            if (FindSTK != null)
                            {
                                STKList.Add(FindSTK);
                            }
                        }
                        if (STKList.Any(x => x.ANC == Row["OLD ANC"].ToString()))
                        {
                            STKDB  STK   = STKList.Find(u => u.ANC == Row["OLD ANC"].ToString());
                            double Value = STK.Value * Convert.ToDouble(Row["OLD Q"].ToString());
                            Value          = Math.Round(Value, 4, MidpointRounding.AwayFromZero);
                            Row["OLD STK"] = Value.ToString();
                            if (PNCRow["OLD STK"].ToString() != string.Empty)
                            {
                                PNCRow["OLD STK"] = (Convert.ToDouble(PNCRow["OLD STK"].ToString()) + Value).ToString();
                            }
                            else
                            {
                                PNCRow["OLD STK"] = Value.ToString();
                            }
                        }
                    }

                    if (Row["NEW ANC"].ToString() != string.Empty)
                    {
                        if (!STKList.Any(x => x.ANC == Row["NEW ANC"].ToString()))
                        {
                            STKDB FindSTK = STKController.Load(Convert.ToInt32(Year), Row["NEW ANC"].ToString());
                            if (FindSTK != null)
                            {
                                STKList.Add(FindSTK);
                            }
                        }
                        if (STKList.Any(x => x.ANC == Row["NEW ANC"].ToString()))
                        {
                            STKDB  STK   = STKList.Find(u => u.ANC == Row["NEW ANC"].ToString());
                            double Value = STK.Value * Convert.ToDouble(Row["NEW Q"].ToString());
                            Value          = Math.Round(Value, 4, MidpointRounding.AwayFromZero);
                            Row["NEW STK"] = Value.ToString();
                            if (PNCRow["NEW STK"].ToString() != string.Empty)
                            {
                                PNCRow["NEW STK"] = (Convert.ToDouble(PNCRow["NEW STK"].ToString()) + Value).ToString();
                            }
                            else
                            {
                                PNCRow["NEW STK"] = Value.ToString();
                            }
                        }
                    }

                    double Delta = 0;
                    if (Row["OLD STK"].ToString() != string.Empty)
                    {
                        Delta = Convert.ToDouble(Row["OLD STK"].ToString());
                    }
                    if (Row["NEW STK"].ToString() != string.Empty)
                    {
                        Delta -= Convert.ToDouble(Row["NEW STK"].ToString());
                    }
                    Delta        = Math.Round(Delta, 4, MidpointRounding.AwayFromZero);
                    Row["Delta"] = Delta.ToString();
                    if (PNCRow["Delta"].ToString() != string.Empty)
                    {
                        PNCRow["Delta"] = (Convert.ToDouble(PNCRow["Delta"].ToString()) + Delta).ToString();
                    }
                    else
                    {
                        PNCRow["Delta"] = Delta.ToString();
                    }
                }
            }

            MainProgram.Self.actionView.PNCListView.SetPNCSpecial(PNCList);
            foreach (STKDB STK in STKList)
            {
                MainProgram.Self.actionView.PNCListView.AddIDCOValue(STK.ANC, STK.IDCO);
            }

            return(true);
        }