Ejemplo n.º 1
0
        public Users()
        {
            InitializeComponent();

            cbSDiv.SelectedIndex = 0;

            globalData.load = false;

            globalData.Div = cbSDiv.SelectedItem.ToString();

            Sql sql1 = new Sql();
            DataTable dt = sql1.GetRecords("exec SelRole");

            if (dt != null)
            {
                cbRoles.DataSource = dt;
                cbRoles.DisplayMember = "role_name";
                cbRoles.ValueMember = "role_id";
                cbRoles.SelectedIndex = 4;
            }

            dt = sql1.GetRecords("exec Region_Select");
            if (dt != null)
            {
                cbRegions.DataSource = dt;
                cbRegions.DisplayMember = "reg_nameRus";
                cbRegions.ValueMember = "reg_id";
            }

            loadData1();
            loadData2();

            globalData.load = true;
        }
Ejemplo n.º 2
0
        private void fillUsersUlpu()
        {
            if (dataGridView1.Rows != null)
            {
                dataGridView1.Rows.Clear();
                dataGridView1.Columns.Clear();
            }

            globalData.load = false;

            Sql sql1 = new Sql();
            DataTable dt1 = sql1.GetRecords("exec SelUserByLPUID @p1", cbULPU.SelectedValue);

            if (dt1 == null)
            {
                MessageBox.Show("Ошибка!", "ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);

            }
            else
            {
                dataGridView1.Columns.Add("user_name", "Региональный представитель");

                foreach (DataRow row in dt1.Rows)
                {
                    dataGridView1.Rows.Add(row.ItemArray[1]);
                }

                dataGridView1.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.DisplayedCells);

            }
            globalData.load = true;
        }
Ejemplo n.º 3
0
 private void CodeName_Activated(object sender, EventArgs e)
 {
     Sql sql1 = new Sql();
     dataGridView1.DataSource = sql1.GetRecords(sel);
     dataGridView1.Columns[0].Visible = false;
     //dataGridView1.FirstDisplayedScrollingRowIndex = clsData.selRow;
 }
Ejemplo n.º 4
0
        private void button1_Click(object sender, EventArgs e)
        {
            InputDialog ind = new InputDialog("Дистрибьютор", "Введите код дистр.(Напр.:20440997)\nНе забудьте добавить РЕГИОН!", true);
            ind.ShowDialog();

            if (ind.DialogResult == DialogResult.Cancel)
                return;
            String code = globalData.input;

            ind = new InputDialog("Дата начала отчётов", "Введите год", true);
            ind.ShowDialog();

            if (ind.DialogResult == DialogResult.Cancel)
                return;
            String yearR = globalData.input;

            ind = new InputDialog("Дата начала отчётов", "Введите месяц в формате 1,2,3..", true);
            ind.ShowDialog();

            if (ind.DialogResult == DialogResult.Cancel)
                return;
            String monthR = globalData.input;

            Sql sql1 = new Sql();
            DataTable dt1 = sql1.GetRecords("exec InsRepDistRight @p1, @p2", code, yearR + "-" + monthR + "-01");
        }
Ejemplo n.º 5
0
        private void btnDel_Click(object sender, EventArgs e)
        {
            Sql sql1 = new Sql();
            sql1.GetRecords("exec DelKosCust @p1", dataGridView1.SelectedRows[0].Cells[0].Value.ToString());

            loadKosCust();
        }
Ejemplo n.º 6
0
        /* Перенести с-ф в другой регион */
        private void button4_Click(object sender, EventArgs e)
        {
            if (globalData.UserAccess == 1)
            {
                try
                {
                    globalData.update = false;
                    Sql sql1 = new Sql();
                    string res = String.Empty;
                    int err1 = 0;

                    foreach (DataGridViewCell cell in _dgvRefDoc.SelectedCells)
                    {
                        if ((_dgvRefDoc.Rows[cell.RowIndex].Cells[0].Value == null && _dgvRefDoc.Rows[cell.RowIndex].Cells[1].Value == null) ||
                            (_dgvRefDoc.Rows[cell.RowIndex].Cells[0].Value.ToString() == "" && _dgvRefDoc.Rows[cell.RowIndex].Cells[1].Value.ToString() == ""))
                            res = sql1.GetRecordsOne("exec UpdReportRefDoc @p1, @p2, @p3, @p4, @p5, @p6", _dgvRefDoc.Rows[cell.RowIndex].Cells[2].Value.ToString(), _dgvRefDoc.Rows[cell.RowIndex].Cells[3].Value.ToString(), comboBox1.SelectedValue, globalData.UserID, dateTimePicker1.Value.Year.ToString() + "-" + dateTimePicker1.Value.Month.ToString() + "-01", cbSDiv.SelectedValue);

                        if (res == "1")
                            err1++;
                    }

                    if (err1 != 0)
                        MessageBox.Show("Кол-во ошибок " + err1.ToString(), "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);

                }
                catch (Exception err)
                {
                    MessageBox.Show("Не удалось обновить продажу. Системная ошибка: " + err.ToString(), "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    this.Close();
                }
            }
        }
Ejemplo n.º 7
0
        public MoveReport(int idRep1, int db1, int count1)
        {
            InitializeComponent();

            Sql sql1 = new Sql();
            DataTable dt1 = sql1.GetRecords("exec SelSubRegionByUserID @p1", globalData.UserID);

            globalData.load = false;
            cbSubReg.DataSource = dt1;
            cbSubReg.DisplayMember = "subreg_nameRus";
            cbSubReg.ValueMember = "subreg_id";
            globalData.load = true;

            tbCount.Text = count1.ToString();
            count = count1;
            idRep = idRep1;
            db = db1;

            if (globalData.Div == "HC")
            {
                tbTail.Visible = true;
                label3.Visible = true;
                tbTail.Text = sql1.GetRecordsOne("exec TailForRaspNew @p1, @p2, @p3", idRep, db, cbSubReg.SelectedValue);
            }
            else
            {
                tbTail.Visible = false;
                label3.Visible = false;
            }
        }
Ejemplo n.º 8
0
        /* ХП */
        public void rent_fill( string name, int role, ComboBox cb, ComboBox cbUser = null, 
                                                                   ComboBox cbDiv = null, 
                                                                   ComboBox cbReg = null, 
                                                                   ComboBox cbRD = null )
        {
            Sql sql1 = new Sql();
            DataTable dt = new DataTable();
            string reg = "0", rd = "0", div = "0", user = globalData.UserID.ToString();
            string _name = "user_name", _id = "user_id";

            if (cbDiv != null)
            {
                if (cbDiv.SelectedValue == null)
                    div = "0";
                else
                    div = cbDiv.SelectedValue.ToString();
            }

            if (cbReg != null)
            {
                if (cbReg.Enabled == false || cbReg.Visible == false || cbReg.SelectedValue == null)
                    reg = "0";
                else
                    reg = cbReg.SelectedValue.ToString();
            }

            if (cbRD != null)
            {
                if (cbRD.Enabled == false || cbRD.Visible == false)
                    rd = "0";
                else
                {
                    if (cbRD.SelectedValue == null)
                        rd = "0";
                    else
                        rd = cbRD.SelectedValue.ToString();
                }
            }
            if (name == "Region" && role == 4)
                user = "******";

            if (name == "UserForDM")
                dt = sql1.GetRecords("exec Rent_Select_" + name + " @p1, @p2, @p3, @p4, @p5, @p6", role, user, div, rd, reg, dtp23.Value.Year.ToString() + "-" + dtp23.Value.Month + "-01");
            else
                dt = sql1.GetRecords("exec Rent_Select_" + name + " @p1, @p2, @p3, @p4, @p5", role, user, div, rd, reg);

            if (name == "Div")
            {
                _name = "sdiv_code";
                _id = "sdiv_id";
            }

            if (name == "Region")
            {
                _name = "reg_nameRus";
                _id = "reg_id";
            }
            fillComboBox(dt, cb, _name, _id);
        }
Ejemplo n.º 9
0
        private void loadButton()
        {
            Sql sql1 = new Sql();

            cbButton.DataSource = sql1.GetRecords("exec SelButton @p1", cbSDiv.SelectedValue);
            cbButton.DisplayMember = "btn_name";
            cbButton.ValueMember = "btn_id";
        }
Ejemplo n.º 10
0
        private void btnSearchCust_Click(object sender, EventArgs e)
        {
            Sql sql1 = new Sql();

            DataTable dt = sql1.GetRecords("exec SelMergeCust @p1, @p2", textBox6.Text, textBox5.Text);

            _dgvMerge.DataSource = dt;
        }
Ejemplo n.º 11
0
        private void btnSearchMat_Click(object sender, EventArgs e)
        {
            Sql sql1 = new Sql();

            DataTable dt = sql1.GetRecords("exec SelMergeMat @p1, @p2, @p3", textBox1.Text, textBox2.Text, textBox3.Text);

            _dgvMerge.DataSource = dt;
        }
Ejemplo n.º 12
0
        private void button1_Click(object sender, EventArgs e)
        {
            Sql sql1 = new Sql();

            sql1.GetRecords("exec Rent_Update_UrtDate @p1", dateRent.Value.Year.ToString() + dateRent.Value.Month.ToString() + "01" );

            MessageBox.Show("Дата отчета успешно установлена!", "Результат");
        }
Ejemplo n.º 13
0
        private void button1_Click(object sender, EventArgs e)
        {
            Sql sql1 = new Sql();
            sql1.GetRecords("exec InsKosCust @p1, @p2, @p3, @p4", cbReg.SelectedValue, cbCust.SelectedValue, cbRegCust.SelectedValue, cbDiv.SelectedValue);

            globalData.load = true;

            MessageBox.Show("Дистрибьютор добавлен");
        }
Ejemplo n.º 14
0
        public AddRowReport(String rep_id, String db_id, bool edit)
        {
            InitializeComponent();

            repID = Convert.ToInt32(rep_id);
            idDB = Convert.ToInt32(db_id);

            Sql sql1 = new Sql();
            DataTable dt1 = sql1.GetRecords("exec selRepKosByID @p1, @p2", rep_id, db_id);

            dateTimePicker1.Value = Convert.ToDateTime(dt1.Rows[0].ItemArray[0].ToString());

            loaddata();

            cbComp.SelectedValue = Convert.ToInt32(dt1.Rows[0].ItemArray[1].ToString());
            cbCust.SelectedValue = Convert.ToInt32(dt1.Rows[0].ItemArray[2].ToString());
            tbDist.Text = dt1.Rows[0].ItemArray[3].ToString();
            cbSubReg.SelectedValue = Convert.ToInt32(dt1.Rows[0].ItemArray[4].ToString());

            if (globalData.Div != "OM")
                cbLPU.SelectedValue = Convert.ToInt32(dt1.Rows[0].ItemArray[5].ToString());

            if (Convert.ToInt32(dt1.Rows[0].ItemArray[6].ToString()) != 0)
            {
                cbGroup.SelectedValue = Convert.ToInt32(dt1.Rows[0].ItemArray[6].ToString());
                cbNom.SelectedValue = Convert.ToInt32(dt1.Rows[0].ItemArray[7].ToString());
            }
            else
                cbGroup.SelectedValue = Convert.ToInt32(dt1.Rows[0].ItemArray[7].ToString());

            changeEnable();

            load = false;

            tbCount.Text = dt1.Rows[0].ItemArray[9].ToString();
            tbPriceEuro.Text = dt1.Rows[0].ItemArray[10].ToString();
            tbPriceRub.Text = dt1.Rows[0].ItemArray[11].ToString();

            load = true;

            if (((!edit) || (dateTimePicker1.Value != Convert.ToDateTime(globalData.CurDate))) && (globalData.UserAccess != 1))
            {
                tbCount.Enabled = false;
                tbPriceEuro.Enabled = false;
                tbPriceRub.Enabled = false;
                cbGroup.Enabled = false;
                cbNom.Enabled = false;
            }
            else
            {
                tbCount.Enabled = true;
                tbPriceEuro.Enabled = true;
                tbPriceRub.Enabled = true;
                cbGroup.Enabled = true;
                cbNom.Enabled = true;
            }
        }
Ejemplo n.º 15
0
        private void button1_Click(object sender, EventArgs e)
        {
            Sql sql1 = new Sql();

            if (this.Text == "Добавление")
                sql1.GetRecords(ins + " @p1 ", textBox1.Text);
            else
                sql1.GetRecords(upd + " @p1, @p2 ", textBox1.Text, mid);
            Close();
        }
Ejemplo n.º 16
0
        private void fillList()
        {
            Sql sql1 = new Sql();
            DataTable dt = sql1.GetRecords("exec SelVisitPlanMonthByUser @p1, @p2", new DateTime(date.Year, date.Month, 1), idUser);

            foreach (DataRow row in dt.Rows)
            {
                visitList.Add(new Visit(Convert.ToInt32(row[0]), idUser));
            }
        }
Ejemplo n.º 17
0
        private void btnDelUserLPU_Click(object sender, EventArgs e)
        {
            int managerID = Convert.ToInt32(manager.SelectedValue);
            int userID = Convert.ToInt32(_dgv2.Rows[_dgv2.SelectedCells[0].RowIndex].Cells[0].Value);

            Sql sql1 = new Sql();
            sql1.GetRecords("exec delUserManager @p1, @p2", managerID, userID);

            loadUserManager(managerID);
        }
Ejemplo n.º 18
0
        private void button1_Click(object sender, EventArgs e)
        {
            Sql sql1 = new Sql();

            if (this.Text == "Добавление")
                sql1.GetRecords(ins + " @p1, @p2 ", textBox1.Text, textBox2.Text);
                //sql1.GetRecords("exec InsReports(" + textBox1.Text + ", " + textBox1.Text + ")");
            else
                sql1.GetRecords(upd + " @p1, @p2, @p3 ", textBox1.Text, textBox2.Text, mid);
            Close();
        }
Ejemplo n.º 19
0
        private void btnDelUserLPU_Click(object sender, EventArgs e)
        {
            LpuRR lpuHT = GetLpuHT();

            Sql sql1 = new Sql();
            DataTable dt1 = new DataTable();

            dt1 = sql1.GetRecords("exec HT_Delete_LPU @p1", lpuHT.ID);

            loadData2();
        }
Ejemplo n.º 20
0
        private void btnDelUserBC_Click(object sender, EventArgs e)
        {
            int userID = Convert.ToInt32(_dgv2.Rows[_dgv2.SelectedCells[0].RowIndex].Cells[0].Value);

            Sql sql1 = new Sql();

            sql1.GetRecords("exec Rent_Delect_UserRent @p1", userID);

            loadUserBC();
            loadData();
        }
Ejemplo n.º 21
0
        private void loadData()
        {
            Sql sql1 = new Sql();

            _dgv1.DataSource = sql1.GetRecords("exec SelTrackers");

            _dgv1.Columns["trac_id"].Visible = false;
            _dgv1.Columns["user_id"].Visible = false;
            _dgv1.Columns["trac_number"].HeaderText = "Номер";
            _dgv1.Columns["user_name"].HeaderText = "Пользователь";
        }
Ejemplo n.º 22
0
        private void btnAddUserLPU_Click(object sender, EventArgs e)
        {
            LpuRR lpuRR = GetLpuRR();

            Sql sql1 = new Sql();
            DataTable dt1 = new DataTable();

            dt1 = sql1.GetRecords("exec HT_Insert_LPU @p1", lpuRR.ID);

            loadData2();
        }
Ejemplo n.º 23
0
        public AEReport(string idRep1, string idDB1)
        {
            try
            {
                InitializeComponent();

                loadData();

                idRep = idRep1;
                idDB = idDB1;

                Sql sql1 = new Sql();
                DataTable dt1 = sql1.GetRecords("exec GetReportByID @p1, @p2", idRep, idDB);

                if (dt1 == null)
                {
                    MessageBox.Show("Не удалось загрузить данные.", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    this.Close();
                }

                cbReg.SelectedValue = Convert.ToInt32(dt1.Rows[0].ItemArray[0]);
                cbSubReg.SelectedValue = Convert.ToInt32(dt1.Rows[0].ItemArray[1]); ;
                dateTimePicker1.Value = Convert.ToDateTime(dt1.Rows[0].ItemArray[2]);
                cbSDiv.SelectedValue = Convert.ToInt32(dt1.Rows[0].ItemArray[3]);

                if (dt1.Rows[0].ItemArray[4].ToString() == "0")
                {
                    lbCheck.Text = "Продажа не распределена";
                    btnOK.Enabled = true;
                }
                else
                {
                    lbCheck.Text = "Продажа распределена. Количество распределений - " + dt1.Rows[0].ItemArray[4].ToString();
                    btnOK.Enabled = false;
                }
            }
            catch (Exception err)
            {
                MessageBox.Show("Не загрузить данные. Системная ошибка: " + err.ToString(), "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
                this.Close();
            }

            if (globalData.UserAccess == 1)
            {
                dateTimePicker1.Enabled = true;
                cbReg.Enabled = true;
            }

            if ((globalData.UserAccess == 5) || (globalData.UserAccess == 6))
            {
                dateTimePicker1.Enabled = false;
                cbReg.Enabled = false;
            }
        }
Ejemplo n.º 24
0
        private void btnClose_Click(object sender, EventArgs e)
        {
            if(mes_id != "0")
            {
                Sql sql1 = new Sql();

                if (cbRead.Checked)
                    sql1.GetRecords("exec UpdMesHide @p1", mes_id);
                else
                    sql1.GetRecords("exec UpdMesRead @p1", mes_id);
            }
        }
Ejemplo n.º 25
0
        public void fillNom()
        {
            Sql sql1 = new Sql();
            DataTable dt = sql1.GetRecords("exec SelNomGroup @p1", globalData.Div);

            if (dt != null)
            {
                cbNomGroup.DataSource = dt;
                cbNomGroup.DisplayMember = "nom_name";
                cbNomGroup.ValueMember = "nom_id";
            }
        }
Ejemplo n.º 26
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            if (tbName.Text != "")
            {
                Sql sql1 = new Sql();

                if (idNom == "0")
                    sql1.GetRecords("exec InsNom @p1, @p2, @p3, @p4, @p5, @p6, @p7, @p8", tbName.Text, cbNomGroup.SelectedValue, cbType.SelectedItem, tbDilCost.Text.Replace(',', '.'), tbSeq.Text, dtYear1.Value.Year, dtYear2.Value.Year, globalData.Div);
                else
                    sql1.GetRecords("exec UpdNom @p1, @p2, @p3, @p4, @p5, @p6, @p7, @p8", idNom, tbName.Text, cbNomGroup.SelectedValue, cbType.SelectedItem, tbDilCost.Text.Replace(',', '.'), tbSeq.Text, dtYear1.Value.Year, dtYear2.Value.Year);

            }
        }
Ejemplo n.º 27
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            Sql sql1 = new Sql();

            string res = sql1.GetRecordsOne("exec InsTracker @p1, @p2, @p3", tracID, tbNumber.Text, cbUser.SelectedValue);

            if (res != "1")
                MessageBox.Show(res, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
            else
            {
                globalData.update = true;
                Close();
            }
        }
Ejemplo n.º 28
0
        private void btnAddUserLPU_Click(object sender, EventArgs e)
        {
            Sql sql1 = new Sql();

            foreach (DataGridViewCell cell in _dgv1.SelectedCells)
            {
                if (_dgv1.Rows[cell.RowIndex].Cells[0].Value.ToString() != String.Empty)
                {
                    sql1.GetRecords("exec InsUserRight @p1, @p2, @p3", _dgv1.Rows[cell.RowIndex].Cells[0].Value.ToString(), cbRegions.SelectedValue, cbSDiv.SelectedItem);
                }
            }

            loadData2();
        }
Ejemplo n.º 29
0
        private void button1_Click(object sender, EventArgs e)
        {
            Sql sql1 = new Sql();

            if (textBox1.Text == string.Empty)
            {
                MessageBox.Show("Вы не ввели счет-фактуру!", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            DataTable dt1 = new DataTable();
            if (MessageBox.Show("Вы уверены, что хотите удалить с-ф:" + textBox1.Text+"? Удаление будет безвозвратным!", "Предупреждение", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes)
                dt1 = sql1.GetRecords("exec DelRefDoc @p1", textBox1.Text);
        }
Ejemplo n.º 30
0
        public fUser(String fio, String login, String role)
        {
            InitializeComponent();
            Sql sql1 = new Sql();

            DataTable dt1 = new DataTable();
            dt1 = sql1.GetRecords("exec GetUserReg @p1", fio);

            if (dt1.Rows.Count > 0)
            {
                _dgv1.DataSource = dt1;

                lbNameTable.Visible = true;
                _dgv1.Visible = true;
                lbRD.Visible = true;
                lbRDName.Visible = true;

                lbRD.Text = sql1.GetRecordsOne("exec GetRDbyUserName @p1", fio);

                _dgv1.Columns["reg_nameRus"].ReadOnly = true;
                _dgv1.Columns["reg_nameRus"].Width = 170;

                if ((role == "Региональный представитель") || (role == "Региональный менеджер"))
                    lbNameTable.Text = "Регионы продаж";
                else if (role == "Региональный директор")
                    lbNameTable.Text = "Cписок подведомственных регионов";
            }
            else
            {
                lbNameTable.Visible = false;
                lbRD.Visible = false;
                lbRDName.Visible = false;
                _dgv1.Visible = false;
            }

            lbFIO.Text = fio;
            lbLogin.Text = login;
            lbRole.Text = role;

            dt1 = sql1.GetRecords("exec GetDivByUserName @p1", fio);
            String temp = "";
            foreach (DataRow row in dt1.Rows)
            {
                if (temp != String.Empty)
                    temp += ", ";
                temp += row[0].ToString();
            }
            lbDiv.Text = temp;
        }