Exemplo n.º 1
0
        private void ValueRefreshData()
        {
            DataTable Value = new DataTable();
            DataRow   FoundRow;
            decimal   Year           = ((NumericUpDown)MainProgram.Self.TabControl.Controls.Find("num_Admin_ValueYear", true).First()).Value;
            TextBox   tb_AdminECCC   = (TextBox)MainProgram.Self.TabControl.Controls.Find("tb_AdminECCC", true).First();
            TextBox   tb_AdminEuro   = (TextBox)MainProgram.Self.TabControl.Controls.Find("tb_AdminEuro", true).First();
            TextBox   tb_AdminDolars = (TextBox)MainProgram.Self.TabControl.Controls.Find("tb_AdminDolars", true).First();
            TextBox   tb_AdminSEK    = (TextBox)MainProgram.Self.TabControl.Controls.Find("tb_AdminSEK", true).First();

            Data_Import.Singleton().Load_TxtToDataTable2(ref Value, "Kurs");

            FoundRow = Value.Select(string.Format("Year LIKE '%{0}%'", Year.ToString())).FirstOrDefault();

            if (FoundRow == null)
            {
                MessageBox.Show("Brak danych do wybranego roku, wprowadź je !");
                return;
            }
            else
            {
                tb_AdminECCC.Text   = FoundRow["ECCC"].ToString();
                tb_AdminEuro.Text   = FoundRow["EURO"].ToString();
                tb_AdminDolars.Text = FoundRow["USD"].ToString();
                tb_AdminSEK.Text    = FoundRow["SEK"].ToString();
            }
        }
Exemplo n.º 2
0
        private void AddRowForHistory(string What, decimal Year)
        {
            DataTable Action   = new DataTable();
            DataTable Historia = new DataTable();

            Data_Import.Singleton().Load_TxtToDataTable2(ref Historia, "History");
            Data_Import.Singleton().Load_TxtToDataTable2(ref Action, "Action");

            DataColumn Col = Action.Columns.Add("History");

            Col.SetOrdinal(0);

            foreach (DataRow ActionRow in Action.Rows)
            {
                if (ActionRow["StartYear"].ToString() == Year.ToString() || ActionRow["StartYear"].ToString() == (Year - 1).ToString() || ActionRow["StartYear"].ToString() == ("BU/" + Year).ToString() || ActionRow["StartYear"].ToString() == ("SA/" + Year).ToString())
                {
                    ActionRow["History"] = What + "/" + Year.ToString();
                    DataRow HistoriaNewRow = Historia.NewRow();
                    HistoriaNewRow.ItemArray = ActionRow.ItemArray;
                    Historia.Rows.Add(HistoriaNewRow);
                }
            }

            Data_Import.Singleton().Save_DataTableToTXT2(ref Historia, "History");
        }
Exemplo n.º 3
0
Arquivo: STK.cs Projeto: bartkkon/SAT
        private void ManulaUpadte(decimal Year)
        {
            DataTable STKTable = new DataTable();

            Data_Import.Singleton().Load_TxtToDataTable2(ref STKTable, "STK");

            if (STKTable.Columns.Contains(Year.ToString()))
            {
                DialogResult Results = MessageBox.Show("Dane STK na rok " + Year.ToString() + " istnieją!. Czy zamienić je ?", "Uwaga", MessageBoxButtons.YesNo);
                if (Results == DialogResult.Yes)
                {
                    STKTable.Columns.Remove(Year.ToString());
                    STKTable.Columns.Remove("STK/" + Year.ToString());
                }
                else
                {
                    return;
                }
            }

            STKTable.Columns.Add(Year.ToString());
            STKTable.Columns.Add("STK/" + Year.ToString());

            Data_Import.Singleton().Save_DataTableToTXT2(ref STKTable, "STK");
            _ = new AddData("Sprowadz dane dla STK", Year);
            //Data.Show();
        }
Exemplo n.º 4
0
        private void ValueSaveData()
        {
            DataTable Value = new DataTable();
            DataRow   NewRow;
            DataRow   FoundRow;
            decimal   Year           = ((NumericUpDown)MainProgram.Self.TabControl.Controls.Find("num_Admin_ValueYear", true).First()).Value;
            TextBox   tb_AdminECCC   = (TextBox)MainProgram.Self.TabControl.Controls.Find("tb_AdminECCC", true).First();
            TextBox   tb_AdminEuro   = (TextBox)MainProgram.Self.TabControl.Controls.Find("tb_AdminEuro", true).First();
            TextBox   tb_AdminDolars = (TextBox)MainProgram.Self.TabControl.Controls.Find("tb_AdminDolars", true).First();
            TextBox   tb_AdminSEK    = (TextBox)MainProgram.Self.TabControl.Controls.Find("tb_AdminSEK", true).First();

            Data_Import.Singleton().Load_TxtToDataTable2(ref Value, "Kurs");

            NewRow = Value.NewRow();

            NewRow["Year"] = Year.ToString();
            NewRow["ECCC"] = tb_AdminECCC.Text;
            NewRow["EURO"] = tb_AdminEuro.Text;
            NewRow["USD"]  = tb_AdminDolars.Text;
            NewRow["SEK"]  = tb_AdminSEK.Text;

            FoundRow = Value.Select(string.Format("Year LIKE '%{0}%'", Year.ToString())).FirstOrDefault();
            if (FoundRow == null)
            {
                Value.Rows.Add(NewRow);
            }
            else
            {
                FoundRow.ItemArray = NewRow.ItemArray.Clone() as object[];
            }

            Data_Import.Singleton().Save_DataTableToTXT2(ref Value, "Kurs");
        }
Exemplo n.º 5
0
        //ładowanie tabeli z akcjami plus wyciągnięcie akcji która nas interesuje
        private DataRow ImportRowAction(string ActionName, decimal Year)
        {
            DataTable ActionList = new DataTable();

            DataRow[] FoundArry;

            Data_Import.Singleton().Load_TxtToDataTable2(ref ActionList, "Action");

            FoundArry = ActionList.Select(string.Format("Name LIKE '%{0}%'", ActionName)).ToArray();

            foreach (DataRow Row in FoundArry.Take(FoundArry.Length))
            {
                if (Row["Name"].ToString() == ActionName && Row["StartYear"].ToString() == Year.ToString())
                {
                    return(Row);
                }
                else if (Row["Name"].ToString() == ActionName && Row["StartYear"].ToString() == (Year - 1).ToString())
                {
                    return(Row);
                }
                else if (Row["Name"].ToString() == ActionName && Row["StartYear"].ToString() == "SA/" + Year.ToString())
                {
                    return(Row);
                }
            }

            return(null);
        }
Exemplo n.º 6
0
        //LoadAction Table
        private DataTable LoadActionTable()
        {
            DataTable ActionList = new DataTable();

            Data_Import.Singleton().Load_TxtToDataTable2(ref ActionList, "Action");

            return(ActionList);
        }
Exemplo n.º 7
0
        private void SaveFromDataGridView(string Link)
        {
            DataTable    Actiontable;
            DataGridView Dg_AdminActionGrid = (DataGridView)Tab_AdminAction.Controls.Find("Dg_AdminActionGrid", true).First();

            Actiontable = (DataTable)(Dg_AdminActionGrid.DataSource);
            Data_Import.Singleton().Save_DataTableToTXT(ref Actiontable, Link);
        }
Exemplo n.º 8
0
Arquivo: STK.cs Projeto: bartkkon/SAT
        private void ClearYear(decimal Year)
        {
            DataTable STKTable = new DataTable();

            Data_Import.Singleton().Load_TxtToDataTable2(ref STKTable, "STK");

            if (STKTable.Columns.Contains(Year.ToString()))
            {
                STKTable.Columns.Remove(Year.ToString());
                STKTable.Columns.Remove("STK/" + Year.ToString());

                Data_Import.Singleton().Save_DataTableToTXT2(ref STKTable, "STK");
            }
        }
Exemplo n.º 9
0
Arquivo: STK.cs Projeto: bartkkon/SAT
        public void STK_LoadFile()
        {
            if (File.Exists(link))
            {
                DataTable Table = new DataTable();
                Data_Import.Singleton().Load_TxtToDataTable2(ref Table, "STK");
            }
            else
            {
                MessageBox.Show("Brak Bazy danych, proszę skontaktować się z administratorem");
            }

            //Dodać odrazu filtrowanie na bierzący rok, chyba przelicza wszystkie - sprawdzić
        }
Exemplo n.º 10
0
        public MainProgram()
        {
            try
            {
                data_Import = Data_Import.Singleton();

                if (!data_Import.CheckConnectionToDataBase())
                {
                    Environment.Exit(0);
                }

                //Widocznoś Maina dla Wszystkich.
                Self = this;

                //Pobranie danych z bazy dla dostępów osób logujących się do programy
                Access = data_Import.Load_Access();
                //Tworzenie Użytkowanika
                CreateUsers NewUsers = new CreateUsers(Access);
                //Inicjalizowanie programu
                InitializeComponent();
                action         = new Action(this, data_Import);
                admin          = new Admin();
                summaryDetails = new SummaryDetails();

                //Budowanie Formsa w zależności od uprawnień
                buildForm.Tab_Control_Add(Access, this, action, summaryDetails, admin, data_Import);

                if (ApplicationDeployment.IsNetworkDeployed)
                {
                    toolStripStatusLabel1.Text = ApplicationDeployment.CurrentDeployment.CurrentVersion.ToString() + " Beta Version";
                }
                else
                {
                    toolStripStatusLabel1.Text = "0.5.0.40  Beta Portable Version";
                }

                if (Environment.UserName.ToString() == "BartkKon")
                {
                    string Link = data_Import.CheckLink();
                    toolStripStatusLabel1.Text = toolStripStatusLabel1.Text + "      " + Link;
                }
            }
            catch (Exception ex)
            {
                LogSingleton.Instance.SaveLog(ex.Message);
            }
        }
Exemplo n.º 11
0
        private void LoadToDataGridView(string Link)
        {
            DataTable    ActionTable              = new DataTable();
            DataGridView Dg_AdminActionGrid       = (DataGridView)Tab_AdminAction.Controls.Find("Dg_AdminActionGrid", true).First();
            GroupBox     Gb_AdminAction_NewColumn = (GroupBox)Tab_AdminAction.Controls.Find("Gb_AdminAction_NewColumn", true).First();
            Label        QuantityColumns          = (Label)MainProgram.Self.TabControl.Controls.Find("Lab_ColumnQuantity", true).First();

            Data_Import.Singleton().Load_TxtToDataTable(ref ActionTable, Link);
            Dg_AdminActionGrid.DataSource = ActionTable;
            foreach (DataGridViewColumn Column in Dg_AdminActionGrid.Columns)
            {
                Column.SortMode = DataGridViewColumnSortMode.NotSortable;
            }
            Dg_AdminActionGrid.Columns[0].Frozen = true;
            Gb_AdminAction_NewColumn.Enabled     = true;
            Dg_AdminActionGrid.AutoSize          = true;
            QuantityColumns.Text = (Dg_AdminActionGrid.Columns.Count - 1).ToString();
        }
Exemplo n.º 12
0
        public void HistorySave()
        {
            DataTable Frozen = new DataTable();
            DataRow   FrozenRow;

            decimal Year = ((NumericUpDown)MainProgram.Self.TabControl.Controls.Find("num_SummaryDetailYear", true).First()).Value;

            Data_Import.Singleton().Load_TxtToDataTable2(ref Frozen, "Frozen");

            FrozenRow = Frozen.Select(string.Format("Year LIKE '%{0}%'", Year.ToString())).First();

            if (FrozenRow != null)
            {
                if (FrozenRow["BU"].ToString() == "Open")
                {
                    DeleteRowFromHistory("BU", Year);
                    AddRowForHistory("BU", Year);
                }
                if (FrozenRow["EA1"].ToString() == "Open")
                {
                    DeleteRowFromHistory("EA1", Year);
                    AddRowForHistory("EA1", Year);
                }
                if (FrozenRow["EA2"].ToString() == "Open")
                {
                    DeleteRowFromHistory("EA2", Year);
                    AddRowForHistory("RA2", Year);
                }
                if (FrozenRow["EA3"].ToString() == "Open")
                {
                    DeleteRowFromHistory("EA3", Year);
                    AddRowForHistory("EA3", Year);
                }
                for (int counter = 1; counter < 13; counter++)
                {
                    if (FrozenRow[counter.ToString()].ToString() == "Open")
                    {
                        DeleteRowFromHistory(counter.ToString(), Year);
                        AddRowForHistory(counter.ToString(), Year);
                    }
                }
            }
        }
Exemplo n.º 13
0
        private void DeleteRowFromHistory(string what, decimal Year)
        {
            DataTable Historia = new DataTable();

            DataRow[] ForDelete;

            Data_Import.Singleton().Load_TxtToDataTable2(ref Historia, "History");

            ForDelete = Historia.Select(string.Format("History LIKE '%{0}%'", what + "/" + Year.ToString())).ToArray();

            if (ForDelete != null)
            {
                foreach (DataRow Delete in ForDelete)
                {
                    Historia.Rows.Remove(Delete);
                }
            }

            Data_Import.Singleton().Save_DataTableToTXT2(ref Historia, "History");
        }
Exemplo n.º 14
0
        private void FrozenRefreshData()
        {
            DataTable Frozen = new DataTable();
            DataRow   FrozenRow;
            decimal   Year = ((NumericUpDown)MainProgram.Self.TabControl.Controls.Find("num_Admin_FrozenYear", true).First()).Value;

            Data_Import.Singleton().Load_TxtToDataTable2(ref Frozen, "Frozen");

            FrozenRow = Frozen.Select(string.Format("Year LIKE '%{0}%'", Year.ToString())).FirstOrDefault();

            if (FrozenRow == null)
            {
                MessageBox.Show("Brak Danego roku w Bazie - dodaj go !!");
                return;
            }
            else
            {
                foreach (DataColumn column in Frozen.Columns)
                {
                    if (column.ColumnName != "Year")
                    {
                        if (FrozenRow[column.ColumnName].ToString() == "Close")
                        {
                            ((ComboBox)MainProgram.Self.TabControl.Controls.Find("Combo_Admin" + column.ColumnName, true).First()).SelectedIndex = 0;
                        }
                        else if (FrozenRow[column.ColumnName].ToString() == "Open")
                        {
                            ((ComboBox)MainProgram.Self.TabControl.Controls.Find("Combo_Admin" + column.ColumnName, true).First()).SelectedIndex = 1;
                        }
                        else if (FrozenRow[column.ColumnName].ToString() == "Approve")
                        {
                            ((ComboBox)MainProgram.Self.TabControl.Controls.Find("Combo_Admin" + column.ColumnName, true).First()).SelectedIndex = 2;
                        }
                        else
                        {
                            ((ComboBox)MainProgram.Self.TabControl.Controls.Find("Combo_Admin" + column.ColumnName, true).First()).SelectedIndex = 0;
                        }
                    }
                }
            }
        }
Exemplo n.º 15
0
        private void Pb_AddData_STK_Close_Click(object sender, EventArgs e)
        {
            Cursor.Current = Cursors.WaitCursor;
            string[]  Row = tb_AddData_Data.Text.Split(new[] { Environment.NewLine }, StringSplitOptions.None);
            DataTable STK = new DataTable();
            DataRow   STKRow;

            Data_Import.Singleton().Load_TxtToDataTable2(ref STK, "STK");

            foreach (string SingleRow in Row)
            {
                string[] Part = SingleRow.Split('\t');
                if (Part.Length > 1)
                {
                    Part[0] = Part[0].Replace(" ", "");
                    STKRow  = STK.Select(string.Format("ANC LIKE '%{0}%'", Part[0])).FirstOrDefault();
                    if (STKRow != null)
                    {
                        STKRow[Year.ToString()]          = "01/00/" + Year.ToString();
                        STKRow["STK/" + Year.ToString()] = Part[1];
                    }
                    else
                    {
                        STKRow                           = STK.NewRow();
                        STKRow["ANC"]                    = Part[0].ToString();
                        STKRow[Year.ToString()]          = "01/00/" + Year.ToString();
                        STKRow["STK/" + Year.ToString()] = Part[1];
                        STK.Rows.Add(STKRow);
                    }
                }
            }

            Data_Import.Singleton().Save_DataTableToTXT2(ref STK, "STK");
            this.Close();
            Cursor.Current = Cursors.Default;
        }
Exemplo n.º 16
0
        private void FrozenSaveData()
        {
            DataTable Frozen = new DataTable();
            DataRow   NewRow;
            DataRow   FoundRow;
            decimal   Year = ((NumericUpDown)MainProgram.Self.TabControl.Controls.Find("num_Admin_FrozenYear", true).First()).Value;

            Data_Import.Singleton().Load_TxtToDataTable2(ref Frozen, "Frozen");

            NewRow = Frozen.NewRow();

            foreach (DataColumn column in Frozen.Columns)
            {
                if (column.ColumnName == "Year")
                {
                    NewRow[column.ColumnName] = Year.ToString();
                }
                else
                {
                    ComboBox ComboBoxFrozen = (ComboBox)MainProgram.Self.TabControl.Controls.Find("Combo_Admin" + column.ColumnName, true).First();
                    NewRow[column.ColumnName] = ComboBoxFrozen.GetItemText(ComboBoxFrozen.SelectedItem);
                }
            }

            FoundRow = Frozen.Select(string.Format("Year LIKE '%{0}%'", Year.ToString())).FirstOrDefault();
            if (FoundRow == null)
            {
                Frozen.Rows.Add(NewRow);
            }
            else
            {
                FoundRow.ItemArray = NewRow.ItemArray.Clone() as object[];
            }

            Data_Import.Singleton().Save_DataTableToTXT2(ref Frozen, "Frozen");
        }
Exemplo n.º 17
0
        private bool ActionSave(bool NewAction)
        {
            DataTable ActionList;

            DataRow[] TableRow;
            DataRow   NewRow = null;
            string    NameAction;
            string    NameAction2;
            decimal   Year;
            bool      New_Year = false;


            ActionList = LoadActionTable();

            Year = ((NumericUpDown)MainProgram.Self.TabControl.Controls.Find("num_Action_YearAction", true).First()).Value;

            if (NewAction)
            {
                NameAction = ((TextBox)MainProgram.Self.TabControl.Controls.Find("tb_Name", true).First()).Text;
                NameAction = NameAction.Replace(";", ",");
                bool NameExist = CheckIfActionNameExist(NameAction, ref ActionList);
                if (NameExist)
                {
                    MessageBox.Show("Please change Action Name, current Name Exist in DataBase");
                    return(false);
                }
                else
                {
                    NewRow = ActionList.NewRow();
                }
            }
            else
            {
                NameAction = ((GroupBox)MainProgram.Self.TabControl.Controls.Find("gb_ActiveAction", true).First()).Text;
                NameAction = NameAction.Replace(";", ",");

                NameAction2 = ((TextBox)MainProgram.Self.TabControl.Controls.Find("tb_Name", true).First()).Text;
                NameAction2 = NameAction2.Replace(";", ",");

                TableRow = ActionList.Select(string.Format("Name LIKE '%{0}%'", NameAction)).ToArray();
                foreach (DataRow Row in TableRow.Take(TableRow.Length))
                {
                    if (Row["StartYear"].ToString() == Year.ToString() && Row["Name"].ToString() == NameAction2)
                    {
                        NewRow = Row;
                    }
                    else if (Row["StartYear"].ToString() == (Year - 1).ToString() && Row["Name"].ToString() == NameAction2)
                    {
                        if (Year.ToString() != Row["StartYear"].ToString())
                        {
                            if (GridCheck(decimal.Parse(Row["StartYear"].ToString())))
                            {
                                Row["StartYear"] = "BU/" + Row["StartYear"].ToString();

                                NewRow   = ActionList.NewRow();
                                New_Year = true;
                            }
                            else
                            {
                                NewRow = Row;
                            }
                        }
                        else
                        {
                            NewRow = Row;
                        }
                    }
                    else if (Row["StartYear"].ToString() == (Year + 1).ToString() && Row["Name"].ToString() == NameAction2)
                    {
                        NewRow = Row;
                    }
                }

                if (NewRow == null)
                {
                    if (NameAction != NameAction2)
                    {
                        DialogResult dialogResult = MessageBox.Show("Do you want change Action Name for this Action?", "Change Action Name", MessageBoxButtons.YesNo);
                        if (dialogResult == DialogResult.No)
                        {
                            MessageBox.Show("Action will be save with Old Name");
                        }
                        else if (dialogResult == DialogResult.Yes)
                        {
                            bool NameExist = CheckIfActionNameExist(NameAction2, ref ActionList);

                            if (NameExist)
                            {
                                MessageBox.Show("Name Exist in Data Base, please change Action Name");
                                return(false);
                            }
                            else
                            {
                                MessageBox.Show("Action will be Save with New Name");
                                TableRow = ActionList.Select(string.Format("Name LIKE '%{0}%'", NameAction)).ToArray();


                                foreach (DataRow Row in TableRow.Take(TableRow.Length))
                                {
                                    if (Row["StartYear"].ToString() == Year.ToString() && Row["Name"].ToString() == NameAction)
                                    {
                                        NewRow = Row;
                                    }
                                    else if (Row["StartYear"].ToString() == (Year - 1).ToString() && Row["Name"].ToString() == NameAction)
                                    {
                                        NewRow = Row;
                                    }
                                }
                                NameAction = NameAction2;
                                ((GroupBox)MainProgram.Self.TabControl.Controls.Find("gb_ActiveAction", true).First()).Text = NameAction2;
                            }
                        }
                    }
                }
            }


            NewRow["Name"] = NameAction;

            NewRow["Description"] = ActionDescription();

            NewRow["Group"]  = ((ComboBox)MainProgram.Self.TabControl.Controls.Find("comBox_Devision", true).First()).Text;
            NewRow["Leader"] = ((ComboBox)MainProgram.Self.TabControl.Controls.Find("comBox_Leader", true).First()).Text;

            NewRow["Status"] = Active_Idea_Action();

            NewRow["Factory"] = ((ComboBox)MainProgram.Self.TabControl.Controls.Find("comBox_Factory", true).First()).Text;


            NewRow["StartYear"]  = Year.ToString();
            NewRow["StartMonth"] = ((ComboBox)MainProgram.Self.TabControl.Controls.Find("comBox_Month", true).First()).Text;

            //ClearDataforUse(((ComboBox)MainProgram.Self.TabControl.Controls.Find("comBox_Month", true).First()).Text);

            NewRow["Platform"] = Platform();

            NewRow["Installation"] = Installation();

            if (((CheckBox)MainProgram.Self.TabControl.Controls.Find("cb_CalcANC", true).First()).Checked)
            {
                NewRow["Calculate"] = "ANC";
                ANCSave(ref NewRow);
            }
            else if (((CheckBox)MainProgram.Self.TabControl.Controls.Find("cb_CalcANCby", true).First()).Checked)
            {
                NewRow["Calculate"] = "ANCSpec";
                ANCSave(ref NewRow);
                NewRow["Calc"]     = ANCCalcby();
                NewRow["CalcMass"] = ANCCalcbyMass();
            }
            else if (((CheckBox)MainProgram.Self.TabControl.Controls.Find("cb_CalcPNC", true).First()).Checked)
            {
                NewRow["Calculate"] = "PNC";
                ANCSave(ref NewRow);
                NewRow["PNC"] = PNCReader();
            }
            else if (((CheckBox)MainProgram.Self.TabControl.Controls.Find("cb_CalcPNCSpec", true).First()).Checked)
            {
                NewRow["Calculate"] = "PNCSpec";
                ANCSave(ref NewRow);
                PNCSpecReader(ref NewRow);
                NewRow["PNCEstyma"] = ((TextBox)MainProgram.Self.TabControl.Controls.Find("TB_EstymacjaPNC", true).First()).Text;
            }

            NewRow["PNCANCPersent"] = ((TextBox)MainProgram.Self.TabControl.Controls.Find("TB_PercentANCPNC", true).First()).Text;

            NewRow["ECCC"] = ECCCReader(NewRow["ECCC"].ToString());

            string[] GridValue;

            //Quantity
            DataGridView Grid = (DataGridView)MainProgram.Self.TabControl.Controls.Find("dg_Quantity", true).First();

            GridValue = GridReader(Grid);
            GridSave(ref NewRow, GridValue, "Quantity", Year);

            //Saving
            Grid      = (DataGridView)MainProgram.Self.TabControl.Controls.Find("dg_Saving", true).First();
            GridValue = GridReader(Grid);
            GridSave(ref NewRow, GridValue, "Saving", Year);

            //ECCC
            Grid      = (DataGridView)MainProgram.Self.TabControl.Controls.Find("dg_ECCC", true).First();
            GridValue = GridReader(Grid);
            GridSave(ref NewRow, GridValue, "ECCC", Year);

            //Sprawdzenie czy to jest Akcja dodatnia czy ujemna
            PozitiveOrNegative(ref NewRow);

            //Sprawdzenie czy jakiś Calc jest nie wpisany - jak nie jest to ma zamienić na same "//////////////"
            IfEmptyCalc(ref NewRow);

            //Dodanie IDCO do pliku
            IDCOAdd(ref NewRow);

            //Zapis kalkulacji poszczególych ANC?PNC
            if (!New_Year)
            {
                PerANC_PNC(ref NewRow, Year);
            }

            //Jesli zmienił się rok to ma do gridów wpisać puste warości
            if (New_Year)
            {
                Calc_Clear(ref NewRow, "Quantity");
                Calc_Clear(ref NewRow, "Saving");
                Calc_Clear(ref NewRow, "ECCC");
                Grid = (DataGridView)MainProgram.Self.TabControl.Controls.Find("dg_Quantity", true).First();
                Grid_Clear(Grid);
                Grid = (DataGridView)MainProgram.Self.TabControl.Controls.Find("dg_Saving", true).First();
                Grid_Clear(Grid);
                Grid = (DataGridView)MainProgram.Self.TabControl.Controls.Find("dg_ECCC", true).First();
                Grid_Clear(Grid);
                //NewRow["IDCO"] = "";
            }


            //Jeśli to była nowa akcja to dodaje wiersz
            if (NewAction || New_Year)
            {
                ActionList.Rows.Add(NewRow);
            }


            //Zapis do pliku
            Data_Import.Singleton().Save_DataTableToTXT2(ref ActionList, "Action");

            return(true);
        }
Exemplo n.º 18
0
Arquivo: STK.cs Projeto: bartkkon/SAT
 public STK()
 {
     link = Data_Import.Singleton().Load_Link("STK");
 }
Exemplo n.º 19
0
Arquivo: STK.cs Projeto: bartkkon/SAT
        private void LoadNewSTKFile(string linkFile)
        {
            DataTable STKTable = new DataTable();
            string    line_help;
            string    ANC;
            int       Year;
            int       Month;
            int       Day;
            float     STK;
            string    Name;
            string    day;
            string    month;
            string    IDCO;

            Data_Import.Singleton().Load_TxtToDataTable2(ref STKTable, "STK");

            if (linkFile == "0")
            {
                MessageBox.Show("Plik nie był generowany od ponad miesiąca!");
            }
            else
            {
                string[] STKFileupdate = File.ReadAllLines(linkFile);

                foreach (string line in STKFileupdate)
                {
                    line_help = line;

                    line_help = line_help.Remove(0, 2);
                    ANC       = line_help.Remove(9);
                    line_help = line_help.Remove(0, 11);
                    Year      = int.Parse(line_help.Remove(2));
                    line_help = line_help.Remove(0, 2);
                    Month     = int.Parse(line_help.Remove(2));
                    line_help = line_help.Remove(0, 2);
                    Day       = int.Parse(line_help.Remove(2));
                    line_help = line_help.Remove(0, 2);
                    STK       = float.Parse(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);


                    Year = 2000 + Year;

                    DataRow FoundRow = STKTable.Select(string.Format("ANC LIKE '%{0}%'", ANC)).FirstOrDefault();

                    if (FoundRow == null)
                    {
                        DataRow NewRow = STKTable.NewRow();
                        NewRow["ANC"]         = ANC;
                        NewRow["Description"] = Name;
                        NewRow["IDCO"]        = IDCO;
                        if (Day < 10)
                        {
                            day = "0" + Day.ToString();
                        }
                        else
                        {
                            day = Day.ToString();
                        }
                        if (Month < 10)
                        {
                            month = "0" + Month.ToString();
                        }
                        else
                        {
                            month = Month.ToString();
                        }

                        if (!STKTable.Columns.Contains(Year.ToString()))
                        {
                            STKTable.Columns.Add(new DataColumn(Year.ToString()));
                            STKTable.Columns.Add(new DataColumn("STK/" + Year));
                        }

                        NewRow[Year.ToString()] = day + "/" + month + "/" + Year.ToString();
                        NewRow["STK/" + Year]   = STK.ToString();
                        STKTable.Rows.Add(NewRow);
                    }
                    else
                    {
                        if (STKTable.Columns.Contains(Year.ToString()))
                        {
                            if (FoundRow["STK/" + Year].ToString() != STK.ToString())
                            {
                                //Co się stanie jak nie jest równy.
                                FoundRow["STK/" + Year] = STK.ToString();
                                if (Day < 10)
                                {
                                    day = "0" + Day.ToString();
                                }
                                else
                                {
                                    day = Day.ToString();
                                }
                                if (Month < 10)
                                {
                                    month = "0" + Month.ToString();
                                }
                                else
                                {
                                    month = Month.ToString();
                                }
                                FoundRow[Year.ToString()] = day + "/" + month + "/" + Year.ToString();
                            }
                            if (FoundRow["IDCO"].ToString() != IDCO)
                            {
                                FoundRow["IDCO"] = IDCO;
                            }
                        }
                        else
                        {
                            //Dodać kolumne z nowym rokiem i dopisać wartość
                            STKTable.Columns.Add(new DataColumn(Year.ToString()));
                            STKTable.Columns.Add(new DataColumn("STK/" + Year));

                            if (Day < 10)
                            {
                                day = "0" + Day.ToString();
                            }
                            else
                            {
                                day = Day.ToString();
                            }
                            if (Month < 10)
                            {
                                month = "0" + Month.ToString();
                            }
                            else
                            {
                                month = Month.ToString();
                            }
                            FoundRow[Year.ToString()] = day + "/" + month + "/" + Year.ToString();
                            FoundRow["STK/" + Year]   = STK.ToString();
                        }
                    }
                }
                Data_Import.Singleton().Save_DataTableToTXT2(ref STKTable, "STK");
            }
        }
Exemplo n.º 20
0
        private void Pb_AddData_Close_Click(object sender, EventArgs e)
        {
            //Action action = new Action();
            Cursor.Current = Cursors.WaitCursor;
            string[] row            = tb_AddData_Data.Text.Split(new[] { Environment.NewLine }, StringSplitOptions.None);
            int      DuplicateCount = 0;
            bool     IFCalc         = false;

            if (row[0] != "")
            {
                if (Jak == "PNC")
                {
                    DataGridView dg_PNC = (DataGridView)MainProgram.Self.TabControl.Controls.Find("dg_PNC", true).First();

                    if (dg_PNC.Rows.Count > 1)
                    {
                        DialogResult result = MessageBox.Show("Do you want replace all PNC in this Action ?", "Warning!", MessageBoxButtons.YesNo);
                        if (result == DialogResult.Yes)
                        {
                            dg_PNC.Rows.Clear();
                            dg_PNC.Columns.Clear();
                            dg_PNC.Columns.Add("PNC", "PNC");
                            dg_PNC.Columns["PNC"].Width    = 63;
                            dg_PNC.Columns["PNC"].SortMode = DataGridViewColumnSortMode.NotSortable;
                            IFCalc = true;
                        }
                        else if (result == DialogResult.No)
                        {
                            DialogResult result2 = MessageBox.Show("Do you want add this PNC to exisitng PNC for this Action ?", "Warning!", MessageBoxButtons.YesNo);
                            if (result2 == DialogResult.Yes)
                            {
                                IFCalc = true;
                            }
                            else if (result2 == DialogResult.No)
                            {
                                IFCalc = false;
                            }
                        }
                    }
                    else
                    {
                        dg_PNC.Rows.Clear();
                        dg_PNC.Columns.Clear();
                        dg_PNC.Columns.Add("PNC", "PNC");
                        dg_PNC.Columns["PNC"].Width    = 63;
                        dg_PNC.Columns["PNC"].SortMode = DataGridViewColumnSortMode.NotSortable;
                        IFCalc = true;
                    }


                    if (IFCalc)
                    {
                        foreach (string OneRow in row)
                        {
                            if (OneRow != "")
                            {
                                var Row = dg_PNC.Rows.Cast <DataGridViewRow>().Where(u => u.Cells["PNC"].Value.ToString().Equals(OneRow)).FirstOrDefault();
                                if (Row == null)
                                {
                                    dg_PNC.Rows.Add(OneRow);
                                }
                                else
                                {
                                    DuplicateCount++;
                                }
                            }
                        }
                    }
                    this.Close();
                    Cursor.Current = Cursors.Default;
                    if (DuplicateCount > 0)
                    {
                        MessageBox.Show($"Was remove {DuplicateCount} Duplicate Value", "Duplicate counter");
                    }
                    return;
                }
                if (Jak == "PNCSpec")
                {
                    DataGridView dg_PNC = (DataGridView)MainProgram.Self.TabControl.Controls.Find("dg_PNC", true).First();

                    if (dg_PNC.Rows.Count > 1)
                    {
                        DialogResult result = MessageBox.Show("Do you want replace all PNC in this Action ?", "Warning!", MessageBoxButtons.YesNo);
                        if (result == DialogResult.Yes)
                        {
                            dg_PNC.Rows.Clear();
                            dg_PNC.Columns.Clear();
                            dg_PNC.Columns.Add("PNC", "PNC");
                            dg_PNC.Columns.Add("OLD ANC", "OLD ANC");
                            dg_PNC.Columns.Add("OLD Q", "Q");
                            dg_PNC.Columns.Add("NEW ANC", "NEW ANC");
                            dg_PNC.Columns.Add("NEW Q", "Q");
                            dg_PNC.Columns["PNC"].Width     = 80;
                            dg_PNC.Columns["OLD ANC"].Width = 65;
                            dg_PNC.Columns["OLD ANC"].DefaultCellStyle.ForeColor = Color.Red;
                            dg_PNC.Columns["OLD Q"].Width = 35;
                            dg_PNC.Columns["OLD Q"].DefaultCellStyle.ForeColor = Color.Red;
                            dg_PNC.Columns["NEW ANC"].Width = 65;
                            dg_PNC.Columns["NEW ANC"].DefaultCellStyle.ForeColor = Color.Green;
                            dg_PNC.Columns["NEW Q"].Width = 35;
                            dg_PNC.Columns["NEW Q"].DefaultCellStyle.ForeColor = Color.Green;
                            dg_PNC.Columns["PNC"].SortMode     = DataGridViewColumnSortMode.NotSortable;
                            dg_PNC.Columns["OLD ANC"].SortMode = DataGridViewColumnSortMode.NotSortable;
                            dg_PNC.Columns["OLD Q"].SortMode   = DataGridViewColumnSortMode.NotSortable;
                            dg_PNC.Columns["NEW ANC"].SortMode = DataGridViewColumnSortMode.NotSortable;
                            dg_PNC.Columns["NEW Q"].SortMode   = DataGridViewColumnSortMode.NotSortable;
                            IFCalc = true;
                        }
                        else if (result == DialogResult.No)
                        {
                            DialogResult result2 = MessageBox.Show("Do you want add this PNC to exisitng PNC for this Action ?", "Warning!", MessageBoxButtons.YesNo);
                            if (result2 == DialogResult.Yes)
                            {
                                IFCalc = true;
                            }
                            else if (result2 == DialogResult.No)
                            {
                                IFCalc = false;
                            }
                        }
                    }
                    else
                    {
                        dg_PNC.Rows.Clear();
                        dg_PNC.Columns.Clear();
                        dg_PNC.Columns.Add("PNC", "PNC");
                        dg_PNC.Columns.Add("OLD ANC", "OLD ANC");
                        dg_PNC.Columns.Add("OLD Q", "Q");
                        dg_PNC.Columns.Add("NEW ANC", "NEW ANC");
                        dg_PNC.Columns.Add("NEW Q", "Q");
                        dg_PNC.Columns["PNC"].Width     = 80;
                        dg_PNC.Columns["OLD ANC"].Width = 65;
                        dg_PNC.Columns["OLD ANC"].DefaultCellStyle.ForeColor = Color.Red;
                        dg_PNC.Columns["OLD Q"].Width = 35;
                        dg_PNC.Columns["OLD Q"].DefaultCellStyle.ForeColor = Color.Red;
                        dg_PNC.Columns["NEW ANC"].Width = 65;
                        dg_PNC.Columns["NEW ANC"].DefaultCellStyle.ForeColor = Color.Green;
                        dg_PNC.Columns["NEW Q"].Width = 35;
                        dg_PNC.Columns["NEW Q"].DefaultCellStyle.ForeColor = Color.Green;
                        dg_PNC.Columns["PNC"].SortMode     = DataGridViewColumnSortMode.NotSortable;
                        dg_PNC.Columns["OLD ANC"].SortMode = DataGridViewColumnSortMode.NotSortable;
                        dg_PNC.Columns["OLD Q"].SortMode   = DataGridViewColumnSortMode.NotSortable;
                        dg_PNC.Columns["NEW ANC"].SortMode = DataGridViewColumnSortMode.NotSortable;
                        dg_PNC.Columns["NEW Q"].SortMode   = DataGridViewColumnSortMode.NotSortable;
                        IFCalc = true;
                    }


                    if (IFCalc)
                    {
                        foreach (string SingleRow in row)
                        {
                            if (SingleRow == string.Empty)
                            {
                                continue;
                            }

                            string[] SelectedRow = SingleRow.Split(';');
                            string   PNC         = SelectedRow[0];
                            string   ECCC        = string.Empty;

                            int Limit = ((SelectedRow.Length - 3) / 2);
                            if (SelectedRow[1].ToString() != string.Empty)
                            {
                                ECCC = "ECCC(" + SelectedRow[1] + ")";
                            }
                            dg_PNC.Rows.Add(PNC, ECCC, string.Empty);

                            dg_PNC.Rows[dg_PNC.Rows.Count - 1].DefaultCellStyle.BackColor = Color.LightBlue;
                            dg_PNC.Rows[dg_PNC.Rows.Count - 1].DefaultCellStyle.Font      = new Font(dg_PNC.Font, FontStyle.Bold);
                            dg_PNC.Rows[dg_PNC.Rows.Count - 1].Cells[1].Style.Font        = new Font(dg_PNC.Font, FontStyle.Regular);
                            dg_PNC.Rows[dg_PNC.Rows.Count - 1].Cells[1].Style.Font        = new Font("Tahoma", 10F, GraphicsUnit.Pixel);

                            for (int counter2 = 2; counter2 < Limit + 2; counter2++)
                            {
                                if (SelectedRow[counter2] != string.Empty || SelectedRow[counter2 + Limit + 1] != string.Empty)
                                {
                                    dg_PNC.Rows.Add(string.Empty, SelectedRow[counter2], SelectedRow[counter2 + 1], SelectedRow[counter2 + Limit + 1], SelectedRow[counter2 + Limit + 2]);
                                }
                                counter2++;
                            }
                        }
                    }
                    this.Close();
                    Cursor.Current = Cursors.Default;
                    return;
                }
            }
            else
            {
                this.Close();
                Cursor.Current = Cursors.Default;
                return;
            }
            if (Jak == "BU" || Jak == "EA1" || Jak == "EA2" || Jak == "EA3")
            {
                NumericUpDown Admin_Year  = (NumericUpDown)MainProgram.Self.TabControl.Controls.Find("num_Admin_YearQuantity", true).First();
                CheckBox      cb_AdminPNC = (CheckBox)MainProgram.Self.TabControl.Controls.Find("cb_AdminPNC", true).First();
                CheckBox      cb_AdminANC = (CheckBox)MainProgram.Self.TabControl.Controls.Find("cb_AdminANC", true).First();
                DataTable     Baza        = new DataTable();
                DataRow       FoundRow;

                int ile;

                if (cb_AdminANC.Checked)
                {
                    Data_Import.Singleton().Load_TxtToDataTable2(ref Baza, "ANC");
                }
                if (cb_AdminPNC.Checked)
                {
                    Data_Import.Singleton().Load_TxtToDataTable2(ref Baza, "PNC");
                }
                switch (Jak)
                {
                case "BU":
                    ile = 1;
                    break;

                case "EA1":
                    ile = 3;
                    break;

                case "EA2":
                    ile = 6;
                    break;

                case "EA3":
                    ile = 9;
                    break;

                default:
                    return;
                }

                if (Baza.Columns.Contains(Jak + "/12/" + Admin_Year.Text))
                {
                    for (int counter = ile; counter <= 12; counter++)
                    {
                        Baza.Columns.Remove(Jak + "/" + counter + "/" + Admin_Year.Text);
                    }
                }
                for (int counter = ile; counter <= 12; counter++)
                {
                    Baza.Columns.Add(new DataColumn(Jak + "/" + counter + "/" + Admin_Year.Text));
                }

                foreach (string OneRow in row)
                {
                    string[] row2 = OneRow.Split('\t');
                    if (row2[0] != "")
                    {
                        if (cb_AdminANC.Checked)
                        {
                            FoundRow = Baza.Select(string.Format("BUANC LIKE '%{0}%'", row2[0])).FirstOrDefault();
                        }
                        else
                        {
                            FoundRow = Baza.Select(string.Format("BUPNC LIKE '%{0}%'", row2[0])).FirstOrDefault();
                        }
                        int zmienna;
                        if (FoundRow != null)
                        {
                            zmienna = ile;
                            for (int counter = 1; counter <= (13 - ile); counter++)
                            {
                                FoundRow[Jak + "/" + zmienna + "/" + Admin_Year.Text] = row2[counter];
                                zmienna++;
                            }
                        }
                        else
                        {
                            DataRow NewRow = Baza.NewRow();
                            NewRow[0] = row2[0];
                            zmienna   = ile;
                            for (int counter = 1; counter <= (13 - ile); counter++)
                            {
                                NewRow[Jak + "/" + zmienna + "/" + Admin_Year.Text] = row2[counter];
                                zmienna++;
                            }
                            Baza.Rows.Add(NewRow);
                        }
                    }
                }
                if (cb_AdminANC.Checked)
                {
                    Data_Import.Singleton().Save_DataTableToTXT2(ref Baza, "ANC");
                }
                if (cb_AdminPNC.Checked)
                {
                    Data_Import.Singleton().Save_DataTableToTXT2(ref Baza, "PNC");
                }
                this.Close();
                Cursor.Current = Cursors.Default;
                return;
            }
            if (Jak == "AddMonthANC" || Jak == "AddMonthPNC")
            {
                NumericUpDown Admin_Year  = (NumericUpDown)MainProgram.Self.TabControl.Controls.Find("num_Admin_YearMonth", true).First();
                NumericUpDown Admin_Month = (NumericUpDown)MainProgram.Self.TabControl.Controls.Find("num_Admin_QuantityMonth", true).First();
                DataTable     Quantity    = new DataTable();
                DataRow       FoundRow;
                string        Miesiac = Admin_Month.Value.ToString() + "/" + Admin_Year.Value.ToString();


                if (Jak == "AddMonthANC")
                {
                    Data_Import.Singleton().Load_TxtToDataTable2(ref Quantity, "ANCMonth");
                }
                if (Jak == "AddMonthPNC")
                {
                    Data_Import.Singleton().Load_TxtToDataTable2(ref Quantity, "PNCMonth");
                }

                if (Quantity.Columns.Contains(Miesiac))
                {
                    Quantity.Columns.Remove(Miesiac);
                }
                Quantity.Columns.Add(new DataColumn(Miesiac));

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

                    if (NewValue[0] != "")
                    {
                        if (Jak == "AddMonthANC")
                        {
                            FoundRow = Quantity.Select(string.Format("ANC LIKE '%{0}%'", NewValue[0])).FirstOrDefault();
                        }
                        else
                        {
                            FoundRow = Quantity.Select(string.Format("PNC LIKE '%{0}%'", NewValue[0])).FirstOrDefault();
                        }
                        if (FoundRow != null)
                        {
                            FoundRow[Miesiac] = NewValue[1];
                        }
                        else
                        {
                            DataRow NewRow = Quantity.NewRow();
                            NewRow[0]       = NewValue[0];
                            NewRow[Miesiac] = NewValue[1];
                            Quantity.Rows.Add(NewRow);
                        }
                    }
                }
                if (Jak == "AddMonthANC")
                {
                    Data_Import.Singleton().Save_DataTableToTXT2(ref Quantity, "ANCMonth");
                }
                if (Jak == "AddMonthPNC")
                {
                    Data_Import.Singleton().Save_DataTableToTXT2(ref Quantity, "PNCMonth");
                }
                this.Close();
                Cursor.Current = Cursors.Default;
                return;
            }
        }
Exemplo n.º 21
0
 public void Pb_AdminAction_SaveAccess_Click(object sender, EventArgs e)
 {
     Cursor.Current = Cursors.WaitCursor;
     SaveFromDataGridView(Data_Import.Singleton().Load_Link("Access"));
     Cursor.Current = Cursors.Default;
 }
Exemplo n.º 22
0
 public void Pb_AdminAction_LoadFrozen_Click(object sender, EventArgs e)
 {
     Cursor.Current = Cursors.WaitCursor;
     LoadToDataGridView(Data_Import.Singleton().Load_Link("Frozen"));
     Cursor.Current = Cursors.Default;
 }
Exemplo n.º 23
0
        //Sprawdzenie czy w Gridach jest coś zapisane już
        private bool GridCheck(decimal Year)
        {
            bool         Grid   = false;
            DataTable    Frozen = new DataTable();
            DataRow      FrozenRow;
            DataGridView Table_Check = (DataGridView)MainProgram.Self.TabControl.Controls.Find("dg_Saving", true).First();

            Data_Import.Singleton().Load_TxtToDataTable2(ref Frozen, "Frozen");

            FrozenRow = Frozen.Select(string.Format("Year LIKE '%{0}%'", Year.ToString())).FirstOrDefault();
            if (FrozenRow == null)
            {
                return(Grid);
            }


            for (int Row = 0; Row < 5; Row++)
            {
                for (int Column = 0; Column < 12; Column++)
                {
                    if (Table_Check.Rows[Row].Cells[Column] != null && Table_Check.Rows[Row].Cells[Column].ToString() != "")
                    {
                        if (Row == 1)
                        {
                            if (FrozenRow["EA3"].ToString() == "Approve")
                            {
                                Grid = true;
                                return(Grid);
                            }
                        }
                        else if (Row == 2)
                        {
                            if (FrozenRow["EA2"].ToString() == "Approve")
                            {
                                Grid = true;
                                return(Grid);
                            }
                        }
                        else if (Row == 3)
                        {
                            if (FrozenRow["EA1"].ToString() == "Approve")
                            {
                                Grid = true;
                                return(Grid);
                            }
                        }
                        else if (Row == 4)
                        {
                            if (FrozenRow["BU"].ToString() == "Approve")
                            {
                                Grid = true;
                                return(Grid);
                            }
                        }
                        else
                        {
                            if (FrozenRow[(Column + 1).ToString()].ToString() == "Approve")
                            {
                                Grid = true;
                                return(Grid);
                            }
                        }
                    }
                }
            }

            return(Grid);
        }