コード例 #1
0
        private void AddInternalOrders_Load(object sender, EventArgs e)
        {
            dateBox.Text = Helper.getDate().ToString("dd.MM.yyyy");
            List <string> list = Helper.getFieldListFromDataTable(DatabaseAPI.getTeamsWithouOrders());

            teamComboBox.DataSource = list;
        }
コード例 #2
0
        private void buttonAdd_Click(object sender, EventArgs e)
        {
            int ID   = int.Parse(teamComboBox.SelectedValue.ToString());
            int code = DatabaseAPI.checkByID(ID, "orders");

            if (Convert.ToBoolean(code))
            {
                MessageBox.Show("Заказ с таким ID уже существует", "Ошибка",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else
            {
                int    customersID = int.Parse(customerComboBox.SelectedValue.ToString());
                string dateStr     = dateBox.Text;
                try
                {
                    int dayCount = int.Parse(durationBox.Text);
                    if (dayCount <= 0)
                    {
                        throw new Exception();
                    }
                    string deadline = date.AddDays(dayCount).ToString("dd.MM.yyyy");
                    DatabaseAPI.addExternalOrders(ID, dateStr, deadline, customersID);
                    this.Close();
                    main.FillGrids();
                } catch
                {
                    MessageBox.Show("Длительность должна быть положительным числом", "Ошибка",
                                    MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
コード例 #3
0
        private void Report_Load(object sender, EventArgs e)
        {
            this.dt = DatabaseAPI.getExOrderById(ID);
            string date     = dt.Rows[0].ItemArray[1].ToString();
            string deadline = dt.Rows[0].ItemArray[2].ToString();
            string sum      = dt.Rows[0].ItemArray[3].ToString();

            reportViewer1.LocalReport.SetParameters(new ReportParameter("ReportParameterID", ID.ToString()));
            reportViewer1.LocalReport.SetParameters(new ReportParameter("ReportParameterDate", date));
            reportViewer1.LocalReport.SetParameters(new ReportParameter("ReportParameterDeadLine", deadline));
            reportViewer1.LocalReport.SetParameters(new ReportParameter("ReportParameterSum", sum));

            bool font    = Convert.ToBoolean(DatabaseAPI.checkAvailability(this.ID, 1));
            bool logo    = Convert.ToBoolean(DatabaseAPI.checkAvailability(this.ID, 2));
            bool cup     = Convert.ToBoolean(DatabaseAPI.checkAvailability(this.ID, 3));
            bool clothes = Convert.ToBoolean(DatabaseAPI.checkAvailability(this.ID, 4));
            bool cover   = Convert.ToBoolean(DatabaseAPI.checkAvailability(this.ID, 5));

            reportViewer1.LocalReport.SetParameters(new ReportParameter("ReportParameterFont", font.ToString()));
            reportViewer1.LocalReport.SetParameters(new ReportParameter("ReportParameterLogo", logo.ToString()));
            reportViewer1.LocalReport.SetParameters(new ReportParameter("ReportParameterCup", cup.ToString()));
            reportViewer1.LocalReport.SetParameters(new ReportParameter("ReportParameterCover", cover.ToString()));
            reportViewer1.LocalReport.SetParameters(new ReportParameter("ReportParameterClothes", clothes.ToString()));

            this.reportViewer1.RefreshReport();
        }
コード例 #4
0
        private void AddExternalOrders_Load(object sender, EventArgs e)
        {
            customerComboBox.DataSource = Helper.getFieldList("customers", "ID");
            List <string> list = Helper.getFieldListFromDataTable(DatabaseAPI.getTeamsWithouOrders());

            teamComboBox.DataSource = list;
            dateBox.Text            = date.ToString("dd.MM.yyyy");;
        }
コード例 #5
0
 private void addLogosFromForm(bool updateStatus)
 {
     if (logoImageLinkBox.Text.Length == 0 && logoDescriptionBox.Text.Length == 0)
     {
         throw new Exception();
     }
     DatabaseAPI.addLogos(id, logoImageLinkBox.Text, logoDescriptionBox.Text, logoTextBox.Text, updateStatus);
 }
コード例 #6
0
 private void addFontsFromForm(bool updateStatus)
 {
     if (fontMarkBox.Text.Length == 0 && fontWidthBox.Text.Length == 0)
     {
         throw new Exception();
     }
     DatabaseAPI.addFonts(id, fontSerifBox.Checked, fontMarkBox.Text, fontWidthBox.Text, fontBoldBox.Checked, updateStatus);
 }
コード例 #7
0
 public void FillGrids()
 {
     DatabaseAPI.GenerateGrid(individualsDataGrid, "individuals");
     DatabaseAPI.GenerateGrid(legalEntitiesDataGrid, "legal entities");
     renderExOrders(externalOrdersDataGrid, "external orders");
     renderIntOrders(internalOrdersDataGrid, "internal orders");
     DatabaseAPI.GenerateGrid(developmentTeamsDataGrid, "development teams");
     DatabaseAPI.GenerateGrid(designersDataGrid, "designers");
     DatabaseAPI.GenerateGrid(employeesDataGrid, "employees");
     translateHeaders();
 }
コード例 #8
0
        public static List <string> getFieldList(string tableName, string fieldName)
        {
            DataTable     data = DatabaseAPI.getTableField(tableName, fieldName);
            List <string> list = new List <string>();

            foreach (DataRow row in data.Rows)
            {
                list.Add(row.ItemArray[0].ToString());
            }
            return(list);
        }
コード例 #9
0
 private void addCoversFromForm(bool updateStatus)
 {
     if (
         coverTypeBox.Text.Length == 0 &&
         coverColorBox.Text.Length == 0 &&
         coverDeviceBox.Text.Length == 0
         )
     {
         throw new Exception();
     }
     DatabaseAPI.addCovers(id, coverTypeBox.Text, coverColorBox.Text, coverDeviceBox.Text, updateStatus);
 }
コード例 #10
0
 private void addClothesFromForm(bool updateStatus)
 {
     if (
         clothesTypeBox.Text.Length == 0 &&
         clothesColorBox.Text.Length == 0 &&
         clothesSizeBox.Text.Length == 0
         )
     {
         throw new Exception();
     }
     DatabaseAPI.addClothes(id, clothesTypeBox.Text, clothesColorBox.Text, clothesSizeBox.Text, clothesTextBox.Text, updateStatus);
 }
コード例 #11
0
        private void buttonAdd_Click(object sender, EventArgs e)
        {
            bool   flag        = true;
            string name        = "";
            string suname      = "";
            string patronymic  = "";
            float  passportID  = 0;
            float  phoneNumber = 0;
            int    ID          = 0;

            try
            {
                ID          = int.Parse(IDBox.Text);
                name        = nameBox.Text;
                suname      = sunameBox.Text;
                patronymic  = patronymicBox.Text;
                passportID  = float.Parse(PIDBox.Text);
                phoneNumber = float.Parse(numberBox.Text);
            }
            catch
            {
                Helper.reportWrongFieldFormat();
                flag = false;
            }
            if (passportID < 9)
            {
                MessageBox.Show("Номер паспорта должен содержать 9 символов!", "Ошибка",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
                flag = false;
            }
            if (phoneNumber < 6)
            {
                MessageBox.Show("Номер должен содержать минимум 6 символов", "Ошибка",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
                flag = false;
            }
            if (flag)
            {
                int code = DatabaseAPI.checkByID(ID, "customers");
                if (Convert.ToBoolean(code))
                {
                    MessageBox.Show("Заказчик с таким ID уже существует", "Ошибка",
                                    MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else
                {
                    DatabaseAPI.addIndividualas(ID, passportID, name, suname, patronymic, phoneNumber);
                    this.Close();
                    main.FillGrids();
                }
            }
        }
コード例 #12
0
 private void renderIntOrders(DataGridView grid, string name)
 {
     if (radioButtonIntUndone.Checked == true)
     {
         DatabaseAPI.GenerateGrid(grid, "getUndoneInOrders", true);
         intOrderBtnControl(true, false, true);
     }
     else
     {
         DatabaseAPI.GenerateGrid(grid, "getDoneInOrders", true);
         intOrderBtnControl(false, true, false);
     }
 }
コード例 #13
0
        private void internalOrdersMarkButton_Click(object sender, EventArgs e)
        {
            int id = Helper.getDataGridSelectedKey(internalOrdersDataGrid, 0);

            if (id >= 0)
            {
                DatabaseAPI.markInOrder(id);
                renderIntOrders(internalOrdersDataGrid, "internal orders");
            }
            else
            {
                Helper.reportTheAbsenceOfAKey();
            }
        }
コード例 #14
0
        private void externalOrdersDeleteButton_Click(object sender, EventArgs e)
        {
            int id = Helper.getDataGridSelectedKey(externalOrdersDataGrid, 0);

            if (id >= 0)
            {
                DatabaseAPI.deleteOrderById(id);
                Helper.generateDelete(externalOrdersDataGrid, "external orders", "orders");
            }
            else
            {
                Helper.reportTheAbsenceOfAKey();
            }
        }
コード例 #15
0
        public static int deleteAdapter(int id, string tableName)
        {
            int code;

            code = DatabaseAPI.checkByID(id, tableName);
            if (code == 0)
            {
                return(1);
            }
            code = DatabaseAPI.deleteByID(id, tableName);
            if (code == 1)
            {
                return(2);
            }
            return(0);
        }
コード例 #16
0
        bool ContactTheDB(bool flag)
        {
            bool chekintConnection;

            DatabaseAPI.CreateConnection();

            try
            {
                if (flag)
                {
                    DatabaseAPI.ConnectionOpen();
                    MessageBox.Show("База данных подключена", "Успешное выполнение", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    FillGrids();
                }
                else
                {
                    DatabaseAPI.ConnectionClose();
                    MessageBox.Show("База данных отключена", "Успешное выполнение", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }

                chekintConnection = true;
            }
            catch (SqlException ex)
            {
                string title;

                switch (ex.Number)
                {
                case -1:
                    title = "Неправильное имя сервера";
                    break;

                case 4060:
                    title = "Неправильное имя базы";
                    break;

                default:
                    title = "Ошибка";
                    break;
                }

                MessageBox.Show(ex.Message, title, MessageBoxButtons.OK, MessageBoxIcon.Error);
                chekintConnection = false;
            }
            return(chekintConnection);
        }
コード例 #17
0
        private void buttonAdd_Click(object sender, EventArgs e)
        {
            int ID   = int.Parse(teamComboBox.SelectedValue.ToString());
            int code = DatabaseAPI.checkOrdersID(ID);

            if (Convert.ToBoolean(code))
            {
                MessageBox.Show("Заказ с таким ID уже существует", "Ошибка",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else
            {
                string date = dateBox.Text;
                DatabaseAPI.addInternalOrders(ID, date);
                this.Close();
                main.FillGrids();
            }
        }
コード例 #18
0
        public static void generateDelete(DataGridView grid, string tableName, string parentTableName)
        {
            int id = getDataGridSelectedKey(grid, 0);

            if (id == -1)
            {
                reportTheAbsenceOfAKey();
            }
            else
            {
                int code = deleteAdapter(id, tableName, parentTableName);
                if (code == 0)
                {
                    DatabaseAPI.GenerateGrid(grid, tableName);
                }
                callDeleteMessage(code, id);
            }
        }
コード例 #19
0
        private void buttonAdd_Click(object sender, EventArgs e)
        {
            bool   flag = true;
            string name = "";
            float  inn  = 0;
            int    ID   = 0;

            try
            {
                ID   = int.Parse(IDBox.Text);
                name = nameBox.Text;
                inn  = float.Parse(innBox.Text);
                if (ID <= 0)
                {
                    throw new Exception();
                }
            } catch
            {
                Helper.reportWrongFieldFormat();
                flag = false;
            }
            if (inn < 12)
            {
                MessageBox.Show("ИНН должен содержать 12 символов", "Ошибка",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
                flag = false;
            }
            if (flag)
            {
                int code = DatabaseAPI.checkByID(ID, "customers");
                if (Convert.ToBoolean(code))
                {
                    MessageBox.Show("Заказчик с таким ID уже существует", "Ошибка",
                                    MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else
                {
                    DatabaseAPI.addLegalEntities(ID, name, inn);
                    this.Close();
                    main.FillGrids();
                }
            }
        }
コード例 #20
0
        private void buttonAdd_Click(object sender, EventArgs e)
        {
            int  teamLeaders = int.Parse(leadersComboBox.SelectedValue.ToString());
            int  ID          = 0;
            bool flag        = true;

            try
            {
                ID = int.Parse(IDBox.Text);
                if (ID <= 0)
                {
                    throw new Exception();
                }
            } catch
            {
                Helper.reportWrongFieldFormat();
                flag = false;
            }

            if (flag)
            {
                int code = DatabaseAPI.checkDevelopmentTeamID(ID);
                if (Convert.ToBoolean(code))
                {
                    MessageBox.Show("Команда с таким ID уже существует", "Ошибка",
                                    MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else
                {
                    string date = dateBox.Text;
                    DatabaseAPI.addDevelopmentTeams(ID, teamLeaders, date);
                    this.Close();
                    main.FillGrids();
                }
            }
        }
コード例 #21
0
 private void buttonAdd_Click(object sender, EventArgs e)
 {
     DatabaseAPI.sendToTheTeam(this.PN, int.Parse(teamsComboBox.SelectedValue.ToString()));
     main.FillGrids();
     this.Close();
 }
コード例 #22
0
 private void buttonOK_Click(object sender, EventArgs e)
 {
     DatabaseAPI.markExOrder(this.ID, int.Parse(textBoxSum.Text));
     main.FillGrids();
     this.Close();
 }
コード例 #23
0
        private void compositionOrder_Load(object sender, EventArgs e)
        {
            DataTable dt;

            dt = DatabaseAPI.getProductsByID(id, 1);
            try
            {
                fontSerifBox.Checked = dt.Rows[0].Field <bool>(1);
                fontMarkBox.Text     = dt.Rows[0].Field <String>(2);
                fontWidthBox.Text    = dt.Rows[0].Field <String>(3);
                fontBoldBox.Checked  = dt.Rows[0].Field <bool>(4);
                fontStatus           = true;
            }
            catch { }
            finally
            {
                Helper.useButtons(fontStatus, fontsDeleteButton, fontsAddButton, fontsSaveButton);
            }
            dt = DatabaseAPI.getProductsByID(id, 2);
            try
            {
                logoImageLinkBox.Text   = dt.Rows[0].Field <String>(1);
                logoDescriptionBox.Text = dt.Rows[0].Field <String>(2);
                logoTextBox.Text        = dt.Rows[0].Field <String>(3);
                logoStatus = true;
            }
            catch { }
            finally
            {
                Helper.useButtons(logoStatus, logosDeleteButton, logosAddButton, logosSaveButton);
            }
            dt = DatabaseAPI.getProductsByID(id, 4);
            try
            {
                clothesTypeBox.Text  = dt.Rows[0].Field <String>(1);
                clothesColorBox.Text = dt.Rows[0].Field <String>(2);
                clothesSizeBox.Text  = dt.Rows[0].Field <String>(3);
                clothesTextBox.Text  = dt.Rows[0].Field <String>(4);
                clothesStatus        = true;
            }
            catch { }
            finally
            {
                Helper.useButtons(clothesStatus, clothesDeleteButton, clothesAddButton, clothesSaveButton);
            }
            dt = DatabaseAPI.getProductsByID(id, 5);
            try
            {
                coverTypeBox.Text   = dt.Rows[0].Field <String>(1);
                coverColorBox.Text  = dt.Rows[0].Field <String>(2);
                coverDeviceBox.Text = dt.Rows[0].Field <String>(3);
                coverStatus         = true;
            }
            catch { }
            finally
            {
                Helper.useButtons(coverStatus, coversDeleteButton, coversAddButton, coversSaveButton);
            }
            dt = DatabaseAPI.getProductsByID(id, 3);
            try
            {
                cupColorBox.Text  = dt.Rows[0].Field <String>(2);
                cupVolumeBox.Text = dt.Rows[0].Field <int>(3).ToString();
                cupStatus         = true;
            }
            catch { }
            finally
            {
                Helper.useButtons(cupStatus, cupsDeleteButton, cupsAddButton, cupsSaveButton);
            }
        }
コード例 #24
0
 private void addCupsFromForm(bool updateStatus)
 {
     DatabaseAPI.addCups(id, cupColorBox.Text, int.Parse(cupVolumeBox.Text), updateStatus);
 }