private void Findshk() { string SqlShkfind = "select Kod,Name,Rcena,Zcena,(select margin_class from classt where id=id_class) as margin_class,(select min_margin from source) as min_margin,Quantity from Dbase where EAN like'%" + txtPshtovar.Text + "%'"; FindshkTable = _SQl.ExecuteSQL(SqlShkfind); if (FindshkTable.Rows.Count == 0) { MessageBox.Show("Товар не найден!", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information); txtPshtovar.Focus(); return; } if (FindshkTable.Rows.Count > 1) { // проверяем не запущена ли форма for (int x = 0; x < this.OwnedForms.Length; x++) { if (this.OwnedForms[x].Name == "Viborform") { this.OwnedForms[x].Focus(); return; } } // Запускаем форму если она не запущена Data.Tovartbl = FindshkTable; // сделать форму с выводом позиций на одном штрихкоде Sform.ownerFormName = "Pform"; Form Viborform = new Viborform(); Viborform.StartPosition = FormStartPosition.CenterScreen; //указываем владельца для формы // Viborform.MdiParent = this.MdiParent; // где containerInstance - это экземпляр контейнера или указатель на MainForm Viborform.Owner = this; Viborform.Show(); txtPshtovar.Text = ""; return; // сделать форму с выводом позиций на одном штрихкоде //for (int i = 0; i < FindshkTable.Rows.Count; i++) //{ // MessageBox.Show(FindshkTable.Rows[i][0].ToString() + " " + FindshkTable.Rows[i][1].ToString(), "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information); //} //return; } lblKodtovara.Text = FindshkTable.Rows[0][0].ToString(); lblnametovar.Text = FindshkTable.Rows[0][1].ToString(); lblPoldzakup.Text = FindshkTable.Rows[0][3].ToString(); txtProzn.Text = FindshkTable.Rows[0][2].ToString(); margin_class = Convert.ToDouble(FindshkTable.Rows[0][4].ToString()); min_margin = Convert.ToDouble(FindshkTable.Rows[0][5].ToString()); txtPkol.Focus(); }
private void ReportSalesform_Load(object sender, EventArgs e) { string SqlCmbLoad = "SELECT * FROM GroupT order by name"; DataTable CmbLoadTable = _SQl.ExecuteSQL(SqlCmbLoad); cmbGruptSales.DataSource = CmbLoadTable; cmbGruptSales.DisplayMember = "Name"; cmbGruptSales.ValueMember = "id"; cmbGruptSales.SelectedValue = 0; }
private void NewUser_Load(object sender, EventArgs e) { cmb_load(); if (this.Text == "Редактирование пользователя") { DataTable Userschange = _SQl.ExecuteSQL("select id,login,pass,id_access from users where id=" + Data.idUser + ""); txtLogin.Text = Userschange.Rows[0][1].ToString(); txtPass.Text = Userschange.Rows[0][2].ToString(); txtPass2.Text = Userschange.Rows[0][2].ToString(); cmbaccess.SelectedValue = Userschange.Rows[0][3].ToString(); } }
public int chek() { while (true) { _SQl.SQL_Query("INSERT INTO BlockT (kod_dbase) Values('Check')"); if (_SQl.uniqBlockT == 0 && _SQl.sql_con.State.ToString() == "Closed") { break; } Thread.Sleep(500); } string SqlQueryChek = "select chek from source"; DataTable ChekTable = _SQl.ExecuteSQL(SqlQueryChek); int Chek = Convert.ToInt32(ChekTable.Rows[0][0].ToString()); Chek += 1; string SqlUpdateChek = "Update Source Set chek =" + Chek + ""; _SQl.SQL_Query(SqlUpdateChek); Chek -= 1; _SQl.SQL_Query("DELETE FROM BlockT WHERE kod_dbase='Check'"); Thread.Sleep(200); return(Chek); }
private void Load_nakladnay() { string QueryNakladnayLoad = "Select kod_dbase,(select name from dbase where kod=kod_dbase) as name,count,zcena,rcena,(select name from suppliers where id=id_suppliers) as sup,datedok,numberdock_sup from incoming where numberdock_mag='" + Data.numDocPrihodRashod + "' "; DataTable NakladnayTable = _SQl.ExecuteSQL(QueryNakladnayLoad); double summPrihod = 0; for (int i = 0; i < NakladnayTable.Rows.Count; i++) { dgvPview.Rows.Add(NakladnayTable.Rows[i][0].ToString(), NakladnayTable.Rows[i][1].ToString(), NakladnayTable.Rows[i][3].ToString(), NakladnayTable.Rows[i][2].ToString(), Math.Round((Convert.ToDouble(NakladnayTable.Rows[i][3].ToString()) * Convert.ToDouble(NakladnayTable.Rows[i][2].ToString())), 2), NakladnayTable.Rows[i][4].ToString()); summPrihod = summPrihod + Convert.ToDouble(dgvPview.Rows[i].Cells[4].Value); //lblSummPrihod.Text = Convert.ToString(Convert.ToDouble(lblSummPrihod.Text) + Convert.ToDouble(dgvPview.Rows[i].Cells[4].Value)); dgvPview.Rows[i].Cells["Chek"].Value = true; } //for (int i = 0; i < dgvPview.Rows.Count; i++) //{ // dgvPview.Rows[i].Cells["Chek"].Value = true; //} lblSummPrihod.Text = summPrihod.ToString(); lbllinedok.Text = dgvPview.Rows.Count.ToString(); cmbSup.Text = NakladnayTable.Rows[0][5].ToString(); txtDokSup.Text = NakladnayTable.Rows[0][7].ToString(); msktxtDateDok.Text = NakladnayTable.Rows[0][6].ToString(); lblNumdokmag.Text = Data.numDocPrihodRashod; //for (int l = 0; l < dgvPview.Rows.Count; l++) //{ // lblSummPrihod.Text = Convert.ToString(Convert.ToDouble(lblSummPrihod.Text) + Convert.ToDouble(dgvPview.Rows[l].Cells[4].Value)); //} }
private void load_cash() { string SQLQueryCash = "select cash from source"; DataTable cash = _SQl.ExecuteSQL(SQLQueryCash); lblCash.Text = cash.Rows[0][0].ToString(); string SQLQueryCashTable = "select type,cashsum,date,comment,(select login from users where id=users_bd) from cash order by date DESC"; DataTable cashtable = _SQl.ExecuteSQL(SQLQueryCashTable); dgvCash.Rows.Clear(); for (int i = 0; i < cashtable.Rows.Count; i++) { dgvCash.Rows.Add(cashtable.Rows[i][0].ToString(), Convert.ToInt32(cashtable.Rows[i][1].ToString()), cashtable.Rows[i][2].ToString(), cashtable.Rows[i][3].ToString(), cashtable.Rows[i][4].ToString()); } }
private void btnok_Click(object sender, EventArgs e) { string login = txtLog.Text; string pass = txtPass.Text; DataTable AccessTable = _SQl.ExecuteSQL("select pass,id_access,id from users where login='******'"); if (AccessTable.Rows.Count != 0) { Sform.id_access = Convert.ToInt32(AccessTable.Rows[0][1].ToString()); string pass_base = AccessTable.Rows[0][0].ToString(); Sform entryfrm = (Sform)this.MdiParent; if (pass == pass_base) { entryfrm.access_users(Sform.id_access); entryfrm.Text = entryfrm.Text + " - " + login + " - " + Sform.fullAdress; Sform.user_bd = login; Sform.id_users = Convert.ToInt32(AccessTable.Rows[0][2].ToString()); //entryfrm.timerChekConnect.Enabled = true; } else { MessageBox.Show("Пароль введен не верно!", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information); Application.Exit(); } this.Close(); } else { MessageBox.Show("Логин или пароль введен не верно!", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information); Application.Exit(); } }
private void btnok_Click(object sender, EventArgs e) { Classform NewClassfrm = (Classform)this.Owner; DataTable DTnclass = _SQl.ExecuteSQL("SELECT max(id) FROM Classt"); if (txtMinMargin.Text != "" && txtnameclass.Text != "") { if (DTnclass.Rows[0][0].ToString() == "") { int id_classn = 1; string txtQueryNewClassAdd = "INSERT INTO Classt VALUES('" + id_classn + "','" + txtnameclass.Text + "'," + txtMinMargin.Text.Replace(',', '.') + ")"; _SQl.SQL_Query(txtQueryNewClassAdd); } else { int id_classn = Convert.ToInt32(DTnclass.Rows[0][0].ToString()) + 1; string txtQueryNewClassAdd = "INSERT INTO Classt VALUES('" + id_classn + "','" + txtnameclass.Text + "'," + txtMinMargin.Text.Replace(',', '.') + ")"; _SQl.SQL_Query(txtQueryNewClassAdd); } } else { MessageBox.Show("Заполните все поля!", "Ошибка!", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } this.Close(); NewClassfrm.load_class(); }
private void Findshk() { string SqlShkfindPer = "select Kod,Name,Rcena,Quantity from Dbase where EAN like'%" + txtPereocshtovar.Text + "%'"; FindshkTablePereoc = _SQl.ExecuteSQL(SqlShkfindPer); if (FindshkTablePereoc.Rows.Count == 0) { MessageBox.Show("Товар не найден!", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information); txtPereocshtovar.Focus(); return; } if (FindshkTablePereoc.Rows.Count > 1) { // проверяем не запущена ли форма for (int x = 0; x < this.OwnedForms.Length; x++) { if (this.OwnedForms[x].Name == "Viborform") { this.OwnedForms[x].Focus(); return; } } // Запускаем форму если она не запущена Data.Tovartbl = FindshkTablePereoc; // сделать форму с выводом позиций на одном штрихкоде Sform.ownerFormName = "Pereocenkaform"; Form Viborform = new Viborform(); Viborform.StartPosition = FormStartPosition.CenterScreen; //указываем владельца для формы // Viborform.MdiParent = this.MdiParent; // где containerInstance - это экземпляр контейнера или указатель на MainForm Viborform.Owner = this; Viborform.Show(); txtPereocshtovar.Text = ""; return; } lblKodtovara.Text = FindshkTablePereoc.Rows[0][0].ToString(); lblnametovar.Text = FindshkTablePereoc.Rows[0][1].ToString(); lblOldRcena.Text = FindshkTablePereoc.Rows[0][2].ToString(); txtNewRcena.Focus(); }
public void GoodsHistoryPriceRoznAndPereozen(string kod, string FullName) { DataTable dtGHP = _SQl.ExecuteSQL("Select numberdock_mag,date,rcena,(Select login From Users WHERE id=users_bd) as NameUsers From incoming WHERE kod_dbase='" + kod + "' ORDER BY date DESC"); lblNameGodds.Text = FullName; for (int i = 0; i < dtGHP.Rows.Count; i++) { dgvInfoPrice.Rows.Add(dtGHP.Rows[i][0].ToString(), dtGHP.Rows[i][1].ToString(), dtGHP.Rows[i][2].ToString(), dtGHP.Rows[i][3].ToString()); } DataTable dtGHPpereocenka = _SQl.ExecuteSQL("Select id,date,newRcena,(Select login From Users WHERE id=users_bd) as NameUsers From Pereocenka WHERE kod_dbase='" + kod + "' ORDER BY date DESC"); //Данные по Переоценке товара for (int l = 0; l < dtGHPpereocenka.Rows.Count; l++) { dgvInfoPrice.Rows.Add(dtGHPpereocenka.Rows[l][0].ToString(), dtGHPpereocenka.Rows[l][1].ToString(), dtGHPpereocenka.Rows[l][2].ToString(), dtGHPpereocenka.Rows[l][3].ToString()); } }
private void ReplaceGroupform_Load(object sender, EventArgs e) { DataTable cmbGroupRepTBL = _SQl.ExecuteSQL("select * from groupt"); cmbgrouprep.DataSource = cmbGroupRepTBL; cmbgrouprep.ValueMember = "id"; cmbgrouprep.DisplayMember = "name"; cmbgrouprep.SelectedValue = 0; }
private void load_cmb_sup() { string SqlCmbLoad = "SELECT * FROM Suppliers order by name"; DataTable CmbLoadTable = _SQl.ExecuteSQL(SqlCmbLoad); cmbSupR.DataSource = CmbLoadTable; cmbSupR.DisplayMember = "Name"; cmbSupR.ValueMember = "id"; cmbSupR.SelectedValue = 0; }
public void load_brand() { DataTable DTbrand = _SQl.ExecuteSQL("select id,Name from brand order by name"); dgvbrand.DataSource = DTbrand; dgvbrand.Columns[0].HeaderCell.Value = "ID"; dgvbrand.Columns[1].HeaderCell.Value = "Название"; dgvbrand.Columns[0].AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells; dgvbrand.Columns[1].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; dgvbrand.Columns[0].ReadOnly = true; dgvbrand.Columns[1].ReadOnly = true; }
private void btnPereocenki_Click(object sender, EventArgs e) { string SQLquerySelectPereocenki = ""; DataTable PereocenkiTBL = new DataTable(); string periodN = func.replace_date_sql(Convert.ToString(dtpPereocenka1.Value)); string periodE = func.replace_date_sql(Convert.ToString(dtpPereocenka2.Value.AddDays(1))); dgvGurPereocenka.Rows.Clear(); SQLquerySelectPereocenki = "select kod_dbase,(select name from dbase where kod=kod_dbase) as nameT,oldrcena,newrcena,date,(select login from users where id=users_bd) as users_bd from pereocenka where date >'" + periodN + "' and date <'" + periodE + "' order by date"; PereocenkiTBL = _SQl.ExecuteSQL(SQLquerySelectPereocenki); for (int i = 0; i < PereocenkiTBL.Rows.Count; i++) { dgvGurPereocenka.Rows.Add(PereocenkiTBL.Rows[i][0].ToString(), PereocenkiTBL.Rows[i][1].ToString(), PereocenkiTBL.Rows[i][2].ToString(), PereocenkiTBL.Rows[i][3].ToString(), PereocenkiTBL.Rows[i][4].ToString(), PereocenkiTBL.Rows[i][5].ToString()); } }
public void load_class() { DataTable DTclass = _SQl.ExecuteSQL("select id,Name,margin_class from Classt order by name"); dgvclass.DataSource = DTclass; dgvclass.Columns[0].HeaderCell.Value = "ID"; dgvclass.Columns[1].HeaderCell.Value = "Название"; dgvclass.Columns[2].HeaderCell.Value = "Наценка"; dgvclass.Columns[0].AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells; dgvclass.Columns[1].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; dgvclass.Columns[2].AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells; dgvclass.Columns[0].ReadOnly = true; dgvclass.Columns[1].ReadOnly = true; dgvclass.Columns[2].ReadOnly = true; }
private void load_cmb() { DataTable DTtcmbclass = _SQl.ExecuteSQL("SELECT * FROM Classt order by name"); cmbclass.DisplayMember = "name"; cmbclass.ValueMember = "id"; cmbclass.DataSource = DTtcmbclass; cmbclass.Text = ""; DataTable DTtcmbbrand = _SQl.ExecuteSQL("SELECT * FROM Brand order by name"); cmbbrand.DisplayMember = "name"; cmbbrand.ValueMember = "id"; cmbbrand.DataSource = DTtcmbbrand; cmbbrand.Text = ""; DataTable DTtcmbgroup = _SQl.ExecuteSQL("SELECT * FROM Groupt order by name"); cmbgroup.DisplayMember = "name"; cmbgroup.ValueMember = "id"; cmbgroup.DataSource = DTtcmbgroup; cmbgroup.Text = ""; DataTable DTtcmbsup = _SQl.ExecuteSQL("SELECT * FROM Suppliers order by name"); cmbsuppliers.DisplayMember = "name"; cmbsuppliers.ValueMember = "id"; cmbsuppliers.DataSource = DTtcmbsup; cmbsuppliers.Text = ""; this.cmbclass.SelectedValue = 0; this.cmbbrand.SelectedValue = 0; this.cmbgroup.SelectedValue = 0; this.cmbsuppliers.SelectedValue = 0; }
public void load_users_form() { DataTable Userstable = _SQl.ExecuteSQL("select id,login,(select LevelUsers from Access_bd where id=id_access) from users order by login"); dgvUsers.DataSource = Userstable; dgvUsers.Columns[0].HeaderCell.Value = "Id"; dgvUsers.Columns[1].HeaderCell.Value = "Пользователь"; dgvUsers.Columns[2].HeaderCell.Value = "Уровень доступа"; dgvUsers.Columns[0].AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells; dgvUsers.Columns[1].AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells; dgvUsers.Columns[2].AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells; dgvUsers.Columns[0].ReadOnly = true; dgvUsers.Columns[1].ReadOnly = true; dgvUsers.Columns[2].ReadOnly = true; }
private void Load_nakladnayRV() { string QueryNakladnayRVLoad = "Select kod_dbase,(select name from dbase where kod=kod_dbase) as name,count,zcena,(select name from suppliers where id=id_suppliers) as sup,date_dock_sup,numberdock_sup from outgoing where numberdock_mag='" + Data.numDocPrihodRashod + "'"; DataTable NakladnayTableRV = _SQl.ExecuteSQL(QueryNakladnayRVLoad); for (int i = 0; i < NakladnayTableRV.Rows.Count; i++) { dgvRview.Rows.Add(NakladnayTableRV.Rows[i][0].ToString(), NakladnayTableRV.Rows[i][1].ToString(), NakladnayTableRV.Rows[i][3].ToString(), NakladnayTableRV.Rows[i][2].ToString(), Math.Round((Convert.ToDouble(NakladnayTableRV.Rows[i][3].ToString()) * Convert.ToDouble(NakladnayTableRV.Rows[i][2].ToString())), 2)); } lbllinedokRV.Text = Convert.ToString(dgvRview.Rows.Count); cmbRVSup.Text = NakladnayTableRV.Rows[0][4].ToString(); txtDokSupRV.Text = NakladnayTableRV.Rows[0][6].ToString(); msktxtDateDokRV.Text = NakladnayTableRV.Rows[0][5].ToString(); lblNumdokmagRV.Text = Data.numDocPrihodRashod; for (int l = 0; l < dgvRview.Rows.Count; l++) { lblSummPrihodRV.Text = Convert.ToString(Convert.ToDouble(lblSummPrihodRV.Text) + Convert.ToDouble(dgvRview.Rows[l].Cells[4].Value)); } }
private void btnok_Click(object sender, EventArgs e) { Brandform NewBrandfrm = (Brandform)this.Owner; DataTable DTnbrand = _SQl.ExecuteSQL("SELECT max(id) FROM Brand"); if (DTnbrand.Rows[0][0].ToString() == "") { int id_brandn = 1; string txtQueryNewBrandAdd = "INSERT INTO Brand VALUES('" + id_brandn + "','" + txtnamebrand.Text + "')"; _SQl.SQL_Query(txtQueryNewBrandAdd); } else { int id_brandn = Convert.ToInt32(DTnbrand.Rows[0][0].ToString()) + 1; string txtQueryNewBrandAdd = "INSERT INTO Brand VALUES('" + id_brandn + "','" + txtnamebrand.Text + "')"; _SQl.SQL_Query(txtQueryNewBrandAdd); } this.Close(); NewBrandfrm.load_brand(); }
private void btnok_Click(object sender, EventArgs e) { Groupform NewGRPsfrm = (Groupform)this.Owner; DataTable DTngrp = _SQl.ExecuteSQL("SELECT max(id) FROM Groupt"); if (DTngrp.Rows[0][0].ToString() == "") { int id_grpn = 1; string txtQueryNewClassAdd = "INSERT INTO groupt VALUES('" + id_grpn + "','" + txtnamegrp.Text + "')"; _SQl.SQL_Query(txtQueryNewClassAdd); } else { int id_grpn = Convert.ToInt32(DTngrp.Rows[0][0].ToString()) + 1; string txtQueryNewClassAdd = "INSERT INTO groupt VALUES('" + id_grpn + "','" + txtnamegrp.Text + "')"; _SQl.SQL_Query(txtQueryNewClassAdd); } this.Close(); NewGRPsfrm.load_group(); }
public void load_sup_form() { DataTable Suptable = _SQl.ExecuteSQL("select * from suppliers order by name"); dgvSup.DataSource = Suptable; dgvSup.Columns[0].HeaderCell.Value = "ID"; dgvSup.Columns[1].HeaderCell.Value = "Наименование"; dgvSup.Columns[2].HeaderCell.Value = "Контактное лицо"; dgvSup.Columns[3].HeaderCell.Value = "Телефон"; dgvSup.Columns[4].HeaderCell.Value = "Адрес"; dgvSup.Columns[0].AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells; dgvSup.Columns[1].AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells; dgvSup.Columns[2].AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells; dgvSup.Columns[3].AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells; dgvSup.Columns[4].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; dgvSup.Columns[0].ReadOnly = true; dgvSup.Columns[1].ReadOnly = true; dgvSup.Columns[2].ReadOnly = true; dgvSup.Columns[3].ReadOnly = true; dgvSup.Columns[4].ReadOnly = true; }
private void btnGurSalesRep_Click(object sender, EventArgs e) { this.Cursor = Cursors.WaitCursor; if (dgvCheki.RowCount != 0) { dgvCheki.DataSource = ""; dgvSostavChek.Rows.Clear(); } string dateSales = func.replace_date_sql(mCalendar.SelectionStart.ToString()); string QuerySalesDayNow = "select Kod,Rcena,Count,Chek,Date,id_type_pay,(Select Users.login from Users where Users.id=sales.users_bd) as user from sales where date like'%" + dateSales + "%' order by chek"; DataTable SalesDayNowTable = _SQl.ExecuteSQL(QuerySalesDayNow); DataTable chekiTable = new DataTable(); chekiTable.Columns.Add("numChek"); chekiTable.Columns.Add("time"); chekiTable.Columns.Add("summChek"); chekiTable.Columns.Add("typeChek"); chekiTable.Columns.Add("userChek"); double summChekAll = 0; int flagUniq = 0; double nal = 0; double beznal = 0; bool CountNull = false; int arrI = 0; string[] arrNullsales = new string[SalesDayNowTable.Rows.Count]; for (int i = 0; i < SalesDayNowTable.Rows.Count; i++) { if (SalesDayNowTable.Rows[i][5].ToString() == "Н") { nal = nal + (Math.Round(Convert.ToDouble(SalesDayNowTable.Rows[i][1].ToString()) * Convert.ToDouble(SalesDayNowTable.Rows[i][2].ToString()), 0)); } else { beznal = beznal + (Math.Round(Convert.ToDouble(SalesDayNowTable.Rows[i][1].ToString()) * Convert.ToDouble(SalesDayNowTable.Rows[i][2].ToString()), 0)); } for (int l = 0; l < SalesDayNowTable.Rows.Count; l++) { for (int idvg = 0; idvg < chekiTable.Rows.Count; idvg++) { if (SalesDayNowTable.Rows[i][3].ToString() == chekiTable.Rows[idvg]["numChek"].ToString()) { flagUniq = 1; break; } } if (flagUniq == 1) { flagUniq = 0; break; } if (SalesDayNowTable.Rows[i][3].ToString() == SalesDayNowTable.Rows[l][3].ToString()) { summChekAll = summChekAll + (Math.Round(Convert.ToDouble(SalesDayNowTable.Rows[l][1].ToString()) * Convert.ToDouble(SalesDayNowTable.Rows[l][2].ToString()), 0)); if (Convert.ToDouble(SalesDayNowTable.Rows[l][2].ToString()) <= 0) { CountNull = true; } } if (l == SalesDayNowTable.Rows.Count - 1) { chekiTable.Rows.Add(SalesDayNowTable.Rows[i][3].ToString(), SalesDayNowTable.Rows[i][4].ToString().Remove(0, 11), summChekAll, SalesDayNowTable.Rows[i][5].ToString(), SalesDayNowTable.Rows[i][6].ToString()); if (CountNull == true) { arrNullsales[arrI] = SalesDayNowTable.Rows[i][3].ToString(); arrI++; CountNull = false; } summChekAll = 0; } } } dgvCheki.DataSource = chekiTable; dgvCheki.Columns["numChek"].HeaderText = "№ Чека"; dgvCheki.Columns["time"].HeaderText = "Время"; dgvCheki.Columns["summChek"].HeaderText = "Сумма"; dgvCheki.Columns["typeChek"].HeaderText = "Тип платежа"; dgvCheki.Columns["userChek"].HeaderText = "Пользователь"; this.Cursor = Cursors.Default; for (int i = 0; i < dgvCheki.Rows.Count; i++) { for (int l = 0; l < arrNullsales.Length; l++) { if (dgvCheki.Rows[i].Cells[0].Value.ToString() == arrNullsales[l]) { dgvCheki.Rows[i].DefaultCellStyle.BackColor = Color.Plum; } } if (dgvCheki.Rows[i].Cells[2].Value.ToString() == "0") { dgvCheki.Rows[i].DefaultCellStyle.BackColor = Color.Plum; } } lblallvir.Text = Convert.ToString(nal + beznal); lblnalvir.Text = Convert.ToString(nal); lblbeznalvir.Text = Convert.ToString(beznal); dgvCheki.Focus(); //dgvCheki.Rows.Clear(); //dgvSostavChek.Rows.Clear(); //string dateSales=func.replace_date_sql(mCalendar.SelectionStart.ToString()); //string QuerySalesDayNow = "select Kod,Rcena,Count,Chek,Date,id_type_pay,(Select Users.login from Users where Users.id=sales.users_bd) as user from sales where date like'%" + dateSales + "%' order by chek"; //DataTable SalesDayNowTable = _SQl.ExecuteSQL(QuerySalesDayNow); //double summChekAll = 0; //int flagUniq = 0; //double nal = 0; //double beznal = 0; //bool CountNull=false ; //for (int i = 0; i < SalesDayNowTable.Rows.Count; i++) //{ // if (SalesDayNowTable.Rows[i][5].ToString() == "Н") // { // nal = nal + (Math.Round(Convert.ToDouble(SalesDayNowTable.Rows[i][1].ToString()) * Convert.ToDouble(SalesDayNowTable.Rows[i][2].ToString()),0)); // } // else // { // beznal = beznal + (Math.Round(Convert.ToDouble(SalesDayNowTable.Rows[i][1].ToString()) * Convert.ToDouble(SalesDayNowTable.Rows[i][2].ToString()),0)); // } // for (int l = 0; l < SalesDayNowTable.Rows.Count; l++) // { // for (int idvg = 0; idvg < dgvCheki.RowCount; idvg++) // { // if (SalesDayNowTable.Rows[i][3].ToString() == dgvCheki.Rows[idvg].Cells["NumChek"].Value.ToString()) // { // flagUniq = 1; // break; // } // } // if (flagUniq == 1) // { // flagUniq = 0; // break; // } // if (SalesDayNowTable.Rows[i][3].ToString() == SalesDayNowTable.Rows[l][3].ToString()) // { // summChekAll = summChekAll + (Math.Round(Convert.ToDouble(SalesDayNowTable.Rows[l][1].ToString()) * Convert.ToDouble(SalesDayNowTable.Rows[l][2].ToString()),0)); // if (Convert.ToDouble(SalesDayNowTable.Rows[l][2].ToString()) <= 0) // { // CountNull = true; // } // } // if (l == SalesDayNowTable.Rows.Count - 1) // { // dgvCheki.Rows.Add(SalesDayNowTable.Rows[i][3].ToString(), SalesDayNowTable.Rows[i][4].ToString().Remove(0, 11), summChekAll, SalesDayNowTable.Rows[i][5].ToString(), SalesDayNowTable.Rows[i][6].ToString()); // if (CountNull == true) // { // dgvCheki.Rows[dgvCheki.Rows.Count-1].DefaultCellStyle.BackColor = Color.Plum; // CountNull = false; // } // summChekAll = 0; // } // } //} //for (int i = 0; i < dgvCheki.Rows.Count; i++) //{ // if (dgvCheki.Rows[i].Cells[2].Value.ToString() == "0") // { // dgvCheki.Rows[i].DefaultCellStyle.BackColor = Color.Plum; // } //} //lblallvir.Text = Convert.ToString(nal + beznal); //lblnalvir.Text = Convert.ToString(nal); //lblbeznalvir.Text = Convert.ToString(beznal); //dgvCheki.Focus(); }
private void Osnovasetform_Load(object sender, EventArgs e) { txtNameCompany.Enabled = false; txtOGRN.Enabled = false; txtINN.Enabled = false; txtcity.Enabled = false; txtInd.Enabled = false; txtDom.Enabled = false; txtstreet.Enabled = false; txtStroenie.Enabled = false; txtLitera.Enabled = false; txtchek.Enabled = false; txtPrefKod.Enabled = false; txtPrefPrihod.Enabled = false; txtPrefRaschod.Enabled = false; txtEanMag.Enabled = false; txtNumberPrihod.Enabled = false; txtNumberRashod.Enabled = false; txtKodTovara.Enabled = false; txtMargin.Enabled = false; txtSMTP.Enabled = false; txtFrom.Enabled = false; txtPassMail.Enabled = false; txtTo.Enabled = false; txtSubj.Enabled = false; txtBodyMail.Enabled = false; txtAttach.Enabled = false; txtTimetimer.Enabled = false; DataTable Docktable = _SQl.ExecuteSQL("select chek,pref_kod,pref_dok_prihod,pref_dok_rashod,ean_mag,number_dok_prihod,number_dok_rashod,kod_mag,min_margin from source"); if (Docktable.Rows.Count > 0) { txtchek.Text = Docktable.Rows[0][0].ToString(); txtPrefKod.Text = Docktable.Rows[0][1].ToString(); txtPrefPrihod.Text = Docktable.Rows[0][2].ToString(); txtPrefRaschod.Text = Docktable.Rows[0][3].ToString(); txtEanMag.Text = Docktable.Rows[0][4].ToString(); txtNumberPrihod.Text = Docktable.Rows[0][5].ToString(); txtNumberRashod.Text = Docktable.Rows[0][6].ToString(); txtKodTovara.Text = Docktable.Rows[0][7].ToString(); txtpathbase.Text = Sform.pathDB; txtPassBase.Text = Sform.passwordDB; txtNamebase.Text = Sform.basename; txtMargin.Text = Docktable.Rows[0][8].ToString(); } DataTable Rektable = _SQl.ExecuteSQL("select inn,ogrn,index_city,street,dom,stroenie,litera,city,urliconame from source"); if (Rektable.Rows.Count > 0) { txtINN.Text = Rektable.Rows[0][0].ToString(); txtOGRN.Text = Rektable.Rows[0][1].ToString(); txtInd.Text = Rektable.Rows[0][2].ToString(); txtstreet.Text = Rektable.Rows[0][3].ToString(); txtDom.Text = Rektable.Rows[0][4].ToString(); txtStroenie.Text = Rektable.Rows[0][5].ToString(); txtLitera.Text = Rektable.Rows[0][6].ToString(); txtcity.Text = Rektable.Rows[0][7].ToString(); txtNameCompany.Text = Rektable.Rows[0][8].ToString(); } DataTable PLUtablesource = _SQl.ExecuteSQL("select PrefVesEan, PLUcount, EAnCount,PLUkodnum from source"); if (PLUtablesource.Rows.Count > 0) { txtPrefVesEan.Text = PLUtablesource.Rows[0][0].ToString(); txtPLUCount.Text = PLUtablesource.Rows[0][1].ToString(); txtVesEanCount.Text = PLUtablesource.Rows[0][2].ToString(); txtPLUkod.Text = PLUtablesource.Rows[0][3].ToString(); String[] printers = PrinterSettings.InstalledPrinters.Cast <string>().ToArray(); String[] printers2 = PrinterSettings.InstalledPrinters.Cast <string>().ToArray(); cmbPrintchek.DataSource = printers; cmbPrintDoc.DataSource = printers2; cmbPrintchek.Text = Sform.NamePrinterChek; cmbPrintDoc.Text = Sform.NamePrinterDok; } DataTable Mailtablesource = _SQl.ExecuteSQL("select SMTP,LoginMail,PassMail,ToMail,SubMail,BodyMail,AttachMail,TimerTime from source"); if (Mailtablesource.Rows.Count > 0) { txtSMTP.Text = Mailtablesource.Rows[0][0].ToString(); txtFrom.Text = Mailtablesource.Rows[0][1].ToString(); txtPassMail.Text = Mailtablesource.Rows[0][2].ToString(); txtTo.Text = Mailtablesource.Rows[0][3].ToString(); txtSubj.Text = Mailtablesource.Rows[0][4].ToString(); txtBodyMail.Text = Mailtablesource.Rows[0][5].ToString(); txtAttach.Text = Mailtablesource.Rows[0][6].ToString(); txtTimetimer.Text = Mailtablesource.Rows[0][7].ToString(); } DataTable Servertablesource = _SQl.ExecuteSQL("select ServerIP,ServerPort from source"); if (Servertablesource.Rows.Count > 0) { txtServerIP.Text = Servertablesource.Rows[0][0].ToString(); txtServerPort.Text = Servertablesource.Rows[0][1].ToString(); } }
private void btnFindTovar_Click(object sender, EventArgs e) { dgvFindT.Rows.Clear(); string QueryFind = ""; if (ckbOst.Checked == true) { QueryFind = "select kod,name,quantity,rcena,ean from dbase where quantity <> 0"; } else { QueryFind = "select kod,name,quantity,rcena,ean from dbase"; } DataTable Findtovartable = _SQl.ExecuteSQL(QueryFind); if (cmbFind.Text == "По Наименованию") { for (int i = 0; i < Findtovartable.Rows.Count; i++) { int fstr = Findtovartable.Rows[i][1].ToString().ToLower().IndexOf(txtFindT.Text.ToLower()); if (fstr >= 0) { dgvFindT.Rows.Add(Findtovartable.Rows[i][0].ToString(), Findtovartable.Rows[i][1].ToString(), Findtovartable.Rows[i][2].ToString(), Findtovartable.Rows[i][3].ToString()); } } } if (cmbFind.Text == "По Штрих коду") { for (int i = 0; i < Findtovartable.Rows.Count; i++) { int fstr = Findtovartable.Rows[i][4].ToString().IndexOf(txtFindT.Text); if (fstr >= 0) { dgvFindT.Rows.Add(Findtovartable.Rows[i][0].ToString(), Findtovartable.Rows[i][1].ToString(), Findtovartable.Rows[i][2].ToString(), Findtovartable.Rows[i][3].ToString()); } } } if (cmbFind.Text == "По Цене") { for (int i = 0; i < Findtovartable.Rows.Count; i++) { if (Findtovartable.Rows[i][3].ToString() == txtFindT.Text) { //int fstr = Findtovartable.Rows[i][3].ToString().IndexOf(txtFindT.Text, 0, txtFindT.Text.Length); // dgvFindT.Rows.Add(Findtovartable.Rows[i][0].ToString(), Findtovartable.Rows[i][1].ToString(), Findtovartable.Rows[i][2].ToString(), Findtovartable.Rows[i][3].ToString()); //} } } } if (cmbFind.Text == "По Коду") { for (int i = 0; i < Findtovartable.Rows.Count; i++) { int fstr = Findtovartable.Rows[i][0].ToString().IndexOf(txtFindT.Text); if (fstr >= 0) { dgvFindT.Rows.Add(Findtovartable.Rows[i][0].ToString(), Findtovartable.Rows[i][1].ToString(), Findtovartable.Rows[i][2].ToString(), Findtovartable.Rows[i][3].ToString()); } } } if (dgvFindT.Rows.Count == 0) { MessageBox.Show("Соответствий не найдено!", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information); } lblFindpos.Text = "Найдено " + dgvFindT.Rows.Count + " позиций"; Findtovartable.Dispose(); }
private void btnRunRep_Click(object sender, EventArgs e) { dgvRepMove.Rows.Clear(); string Kod = ""; DataTable RepSales = new DataTable(); DataTable RepIncom = new DataTable(); DataTable RepOutgoin = new DataTable(); DataTable AllinfoGoods = new DataTable(); string numDoc = ""; string doc = ""; AllinfoGoods.Columns.Add("kod"); AllinfoGoods.Columns.Add("name"); AllinfoGoods.Columns.Add("count"); AllinfoGoods.Columns.Add("cena"); AllinfoGoods.Columns.Add("numdoc"); AllinfoGoods.Columns.Add("date", typeof(DateTime)); double countSales = 0; //double countIncom = 0; //double countOutgoin = 0; string PeriodN = func.replace_date_sql(Convert.ToString(dtpin.Value)); string PeriodE = func.replace_date_sql(Convert.ToString(dtpout.Value.AddDays(1))); for (int i = 0; i < lstGoods.Items.Count; i++) { Kod = lstGoods.Items[i].ToString().Remove(lstGoods.Items[i].ToString().IndexOf(" --")); RepSales = _SQl.ExecuteSQL("select kod,(select name from dbase WHERE dbase.kod=sales.kod) as name,count,rcena,chek,date From sales where kod='" + Kod + "' and date>'" + PeriodN + "' and date<'" + PeriodE + "' ORDER BY date"); RepIncom = _SQl.ExecuteSQL("select kod_dbase,(select name from dbase WHERE dbase.kod=Incoming.kod_dbase) as name,count,zcena,numberdock_mag,date From Incoming where kod_dbase='" + Kod + "' and date>'" + PeriodN + "' and date<'" + PeriodE + "' ORDER BY date"); RepOutgoin = _SQl.ExecuteSQL("select kod_dbase,(select name from dbase WHERE dbase.kod=Outgoing.kod_dbase) as name,count,zcena,numberdock_mag,date From Outgoing where kod_dbase='" + Kod + "' and date>'" + PeriodN + "' and date<'" + PeriodE + "' ORDER BY date"); for (int isales = 0; isales < RepSales.Rows.Count; isales++) { AllinfoGoods.Rows.Add(RepSales.Rows[isales][0].ToString(), RepSales.Rows[isales][1].ToString(), RepSales.Rows[isales][2].ToString(), RepSales.Rows[isales][3].ToString(), RepSales.Rows[isales][4].ToString(), RepSales.Rows[isales][5].ToString()); } for (int isales = 0; isales < RepIncom.Rows.Count; isales++) { AllinfoGoods.Rows.Add(RepIncom.Rows[isales][0].ToString(), RepIncom.Rows[isales][1].ToString(), RepIncom.Rows[isales][2].ToString(), RepIncom.Rows[isales][3].ToString(), RepIncom.Rows[isales][4].ToString(), RepIncom.Rows[isales][5].ToString()); } for (int isales = 0; isales < RepOutgoin.Rows.Count; isales++) { AllinfoGoods.Rows.Add(RepOutgoin.Rows[isales][0].ToString(), RepOutgoin.Rows[isales][1].ToString(), RepOutgoin.Rows[isales][2].ToString(), RepOutgoin.Rows[isales][3].ToString(), RepOutgoin.Rows[isales][4].ToString(), RepOutgoin.Rows[isales][5].ToString()); } DataView dVAllinfoGoods = new DataView(AllinfoGoods); dVAllinfoGoods.Sort = "date ASC"; AllinfoGoods = dVAllinfoGoods.ToTable(); if (AllinfoGoods.Rows.Count == 0) { dgvRepMove.Rows.Add(Kod, lstGoods.Items[i].ToString()); dgvRepMove.Rows[dgvRepMove.Rows.Count - 1].DefaultCellStyle.BackColor = Color.LightGray; dgvRepMove.Rows.Add("", "Итого:", "0", ""); } for (int irow = -1; irow < AllinfoGoods.Rows.Count; irow++) { if (irow == -1) { dgvRepMove.Rows.Add(AllinfoGoods.Rows[0][0].ToString(), AllinfoGoods.Rows[0][1].ToString()); dgvRepMove.Rows[dgvRepMove.Rows.Count - 1].DefaultCellStyle.BackColor = Color.LightGray; } else { if (irow != AllinfoGoods.Rows.Count - 1 && irow != -1) { numDoc = AllinfoGoods.Rows[irow][4].ToString(); if (numDoc.IndexOf(pref_dok_prihod) != -1) { doc = "Приходная накладная № "; } if (numDoc.IndexOf(pref_dok_rashod) != -1) { doc = "Расходная накладная № "; } if (numDoc.IndexOf(pref_dok_rashod) == -1 && numDoc.IndexOf(pref_dok_prihod) == -1) { doc = "Чек № "; } countSales = countSales + Convert.ToDouble(AllinfoGoods.Rows[irow][2].ToString()); dgvRepMove.Rows.Add("", doc + AllinfoGoods.Rows[irow][4].ToString() + " -- " + AllinfoGoods.Rows[irow][5].ToString(), AllinfoGoods.Rows[irow][2].ToString(), AllinfoGoods.Rows[irow][3].ToString()); } else { numDoc = AllinfoGoods.Rows[irow][4].ToString(); if (numDoc.IndexOf(pref_dok_prihod) != -1) { doc = "Приходная накладная № "; } if (numDoc.IndexOf(pref_dok_rashod) != -1) { doc = "Расходная накладная № "; } if (numDoc.IndexOf(pref_dok_rashod) == -1 && numDoc.IndexOf(pref_dok_prihod) == -1) { doc = "Чек № "; } countSales = countSales + Convert.ToDouble(AllinfoGoods.Rows[irow][2].ToString()); dgvRepMove.Rows.Add("", doc + AllinfoGoods.Rows[irow][4].ToString() + " -- " + AllinfoGoods.Rows[irow][5].ToString(), AllinfoGoods.Rows[irow][2].ToString(), AllinfoGoods.Rows[irow][3].ToString()); dgvRepMove.Rows.Add("", "Итого:", countSales, ""); countSales = 0; } } } AllinfoGoods.Clear(); } }
private void ReportCashAll() { dgvRepCash.Rows.Clear(); int monthN = dtpMonth.Value.Month; int yearN = dtpMonth.Value.Year; int yearE = dtpMonth.Value.Year; int monthE = dtpMonth.Value.Month + 1; int dayM = DateTime.DaysInMonth(yearN, monthN); if (monthE > 12) { monthE = 1; yearE = yearE + 1; } string periodN = yearN.ToString() + "-" + monthN.ToString().PadLeft(2, '0') + "-" + "01"; string periodE = yearE.ToString() + "-" + monthE.ToString().PadLeft(2, '0') + "-" + "01"; string QueryReportCashSales = "Select rcena,count,date,zcena,id_type_pay from sales where date >'" + periodN + "' and date <'" + periodE + "' order by date"; string QueryReportCashIncoming = "Select count,zcena,date from incoming where date >'" + periodN + "' and date <'" + periodE + "' order by date"; string QueryReportCashOutgoing = "Select count,zcena,date from outgoing where date >'" + periodN + "' and date <'" + periodE + "' order by date"; DataTable ReportCashSalesTBL = _SQl.ExecuteSQL(QueryReportCashSales); DataTable ReportCashIncomingTBL = _SQl.ExecuteSQL(QueryReportCashIncoming); DataTable ReportCashOutgoingTBL = _SQl.ExecuteSQL(QueryReportCashOutgoing); for (int day = 1; day < (dayM + 1); day++) { dgvRepCash.Rows.Add(day.ToString().PadLeft(2, '0') + "." + monthN.ToString().PadLeft(2, '0') + "." + yearN); } double summR = 0; double summZ = 0; double nal = 0; double beznal = 0; double summRashod = 0; double summZakup = 0; for (int irow = 0; irow < dgvRepCash.Rows.Count; irow++) { string dateDGV = dgvRepCash.Rows[irow].Cells["date"].Value.ToString(); ///Таблица продажи----------------------------------------------- for (int iSales = 0; iSales < ReportCashSalesTBL.Rows.Count; iSales++) { string dateSales = ReportCashSalesTBL.Rows[iSales][2].ToString().Remove(10); if (dateSales == dateDGV) { if (ReportCashSalesTBL.Rows[iSales][4].ToString().ToLower() == "н") { nal += Math.Round((Convert.ToDouble(ReportCashSalesTBL.Rows[iSales][0].ToString()) * Convert.ToDouble(ReportCashSalesTBL.Rows[iSales][1].ToString())), 0); } else { beznal += Math.Round((Convert.ToDouble(ReportCashSalesTBL.Rows[iSales][0].ToString()) * Convert.ToDouble(ReportCashSalesTBL.Rows[iSales][1].ToString())), 0); } summR = summR + Math.Round((Convert.ToDouble(ReportCashSalesTBL.Rows[iSales][0].ToString()) * Convert.ToDouble(ReportCashSalesTBL.Rows[iSales][1].ToString())), 0); summZ = summZ + Math.Round((Convert.ToDouble(ReportCashSalesTBL.Rows[iSales][3].ToString()) * Convert.ToDouble(ReportCashSalesTBL.Rows[iSales][1].ToString())), 2); } if (ReportCashSalesTBL.Rows.Count - 1 == iSales) { dgvRepCash.Rows[irow].Cells["purchase"].Value = summZ; dgvRepCash.Rows[irow].Cells["nal"].Value = nal; dgvRepCash.Rows[irow].Cells["beznal"].Value = beznal; dgvRepCash.Rows[irow].Cells["sales"].Value = summR; dgvRepCash.Rows[irow].Cells["income"].Value = (summR - summZ); dgvRepCash.Rows[irow].Cells["marginofday"].Value = Math.Round(((summR / summZ) - 1) * 100, 2); summR = 0; summZ = 0; beznal = 0; nal = 0; } } ///Таблица приходы----------------------------------------------- for (int iIncom = 0; iIncom < ReportCashIncomingTBL.Rows.Count; iIncom++) { string dateIncom = ReportCashIncomingTBL.Rows[iIncom][2].ToString().Remove(10); if (dateIncom == dateDGV) { summZakup = summZakup + Math.Round((Convert.ToDouble(ReportCashIncomingTBL.Rows[iIncom][0].ToString()) * Convert.ToDouble(ReportCashIncomingTBL.Rows[iIncom][1].ToString())), 2); } if (ReportCashIncomingTBL.Rows.Count - 1 == iIncom) { dgvRepCash.Rows[irow].Cells["purchased"].Value = summZakup; summZakup = 0; } } ///Таблица Расходы----------------------------------------------- /// for (int iRashod = 0; iRashod < ReportCashOutgoingTBL.Rows.Count; iRashod++) { string dateRashod = ReportCashOutgoingTBL.Rows[iRashod][2].ToString().Remove(10); if (dateRashod == dateDGV) { summRashod = summRashod + Math.Round((Convert.ToDouble(ReportCashOutgoingTBL.Rows[iRashod][0].ToString()) * Convert.ToDouble(ReportCashOutgoingTBL.Rows[iRashod][1].ToString())), 2); } if (ReportCashOutgoingTBL.Rows.Count - 1 == iRashod) { dgvRepCash.Rows[irow].Cells["salvage"].Value = summRashod; summRashod = 0; } } } double itogZsumm = 0; double itogRsumm = 0; double itogCash = 0; double itogZakup = 0; double itogVosvart = 0; double itogSpisanie = 0; double itogNal = 0; double itogBeznal = 0; for (int irowItog = 0; irowItog < dgvRepCash.Rows.Count; irowItog++) { itogCash = itogCash + Convert.ToDouble(dgvRepCash.Rows[irowItog].Cells[5].Value); itogZsumm = itogZsumm + Convert.ToDouble(dgvRepCash.Rows[irowItog].Cells[4].Value); itogRsumm = itogRsumm + Convert.ToDouble(dgvRepCash.Rows[irowItog].Cells[1].Value); //itogVosvart = itogVosvart + Convert.ToDouble(dgvRepCash.Rows[irowItog].Cells[5].Value); itogSpisanie = itogSpisanie + Convert.ToDouble(dgvRepCash.Rows[irowItog].Cells[8].Value); itogZakup = itogZakup + Convert.ToDouble(dgvRepCash.Rows[irowItog].Cells[6].Value); itogNal = itogNal + Convert.ToDouble(dgvRepCash.Rows[irowItog].Cells[2].Value); itogBeznal = itogBeznal + Convert.ToDouble(dgvRepCash.Rows[irowItog].Cells[3].Value); if (irowItog == dgvRepCash.Rows.Count - 1) { dgvRepCash.Rows.Add("Итоги", itogRsumm, itogNal, itogBeznal, itogZsumm, itogCash, itogZakup, itogVosvart, itogSpisanie, Math.Round((((itogRsumm / itogZsumm) - 1) * 100), 2)); return; } } }
public void chek_fields() { string[] baseColName = { "Access_bd", "Brand", "BlockT", "Cash", "ClassT", "Dbase", "Groupt", "Incoming", "Outgoing", "Pereocenka", "Sales", "Source", "Suppliers", "Users" }; string[] Access_bd_Fields = { "id", "LevelUsers" }; //Access_bd string[] Access_bd_FieldsType = { "INTEGER PRIMARY KEY AUTOINCREMENT", "TEXT" }; //Access_bd string[] Brand_Fields = { "id", "name" }; //"Brand" string[] Brand_FieldsType = { "INTEGER PRIMARY KEY AUTOINCREMENT", "TEXT" }; //"Brand" string[] ClassT_Fields = { "id", "name", "margin_class" }; //"ClassT" string[] ClassT_FieldsType = { "INTEGER PRIMARY KEY AUTOINCREMENT", "TEXT", "REAL" }; //"ClassT" string[] Dbase_Fields = { "Kod", "Name", "Quantity", "Zcena", "Rcena", "id_Group", "id_Class", "id_Brand", "id_Suppliers", "EAN", "kod_osnova", "obem_spisanie", "plukod", "life_goods" }; //Dbase string[] Dbase_FieldsType = { "TEXT PRIMARY KEY", "TEXT", "REAL", "REAL", "REAL", "INT", "INT", "INT", "INT", "TEXT", "TEXT", "REAL", "INT", "INT" }; //Dbase string[] Groupt_Fields = { "id", "name" }; // Groupt string[] Groupt_FieldsType = { "INTEGER PRIMARY KEY AUTOINCREMENT", "TEXT" }; // Groupt string[] Incoming_Fields = { "id", "kod_dbase", "count", "count_s", "zcena", "numberdock_mag", "datedok", "id_suppliers", "status", "date", "numberdock_sup", "rcena", "users_bd" }; // Incoming string[] Incoming_FieldsType = { "INTEGER PRIMARY KEY AUTOINCREMENT", "TEXT", "REAL", "REAL", "REAL", "TEXT", "TEXT", "INTEGER", "NUMERIC", "DATETIME", "TEXT", "REAL", "INT" }; // Incoming string[] Outgoing_Fields = { "id", "kod_dbase", "count", "zcena", "numberdock_mag", "id_suppliers", "date", "id_incoming", "numberdock_sup", "date_dock_sup", "users_bd" }; // Outgoing string[] Outgoing_FieldsType = { "INTEGER PRIMARY KEY AUTOINCREMENT", "TEXT", "REAL", "REAL", "TEXT", "INTEGER", "DATETIME", "INTEGER", "TEXT", "TEXT", "INT" }; // Outgoing string[] Pereocenka_Fields = { "id", "kod_dbase", "oldRcena", "newRcena", "date", "users_bd" }; // Pereocenka string[] Pereocenka_FieldsType = { "INTEGER PRIMARY KEY AUTOINCREMENT", "TEXT", "REAL", "REAL", "DATETIME", "INT" }; // Pereocenka string[] Sales_Fields = { "Kod", "Rcena", "Count", "Chek", "Date", "Zcena", "numberdock_mag_incoming", "id_incoming", "id_type_pay", "users_bd" }; // Sales string[] Sales_FieldsType = { "TEXT", "REAL", "REAL", "INT", "DATETIME", "REAL", "TEXT", "INT", "TEXT", "INT" }; // Sales string[] Source_Fields = { "chek", "pref_kod", "pref_dok_prihod", "pref_dok_rashod", "ean_mag", "urliconame", "kod_mag", "number_dok_rashod", "number_dok_prihod", "min_margin", "ogrn", "inn", "index_city", "street", "dom", "stroenie", "litera", "PrefVesEan", "PLUcount", "EAnCount", "PLUkodnum", "PrinterChek", "PrinterDok", "City", "SMTP", "LoginMail", "PassMail", "ToMail", "SubMail", "BodyMail", "AttachMail", "TimerTime", "ServerIP", "ServerPort", "ClientIP", "ClientPort", "Cash" }; // Source string[] Source_FieldsType = { "INT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "INT", "INT", "INT", "REAL", "NUMERIC", "NUMERIC", "NUMERIC", "TEXT", "NUMERIC", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "INT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "INT" }; // Source string[] Suppliers_Fields = { "id", "name", "person", "phone", "adress" }; // Suppliers string[] Suppliers_FieldsType = { "INTEGER PRIMARY KEY AUTOINCREMENT", "TEXT", "TEXT", "TEXT", "TEXT" }; // Suppliers string[] Users_Fields = { "id", "login", "pass", "id_access" }; // Users string[] Users_FieldsType = { "INTEGER PRIMARY KEY AUTOINCREMENT", "TEXT", "TEXT", "INT" }; // Users string[] Cash_Fields = { "type", "cashsum", "date", "comment", "users_bd" }; // Cash string[] Cash_FieldsType = { "TEXT", "INT", "DATETIME", "TEXT", "INT" }; // Cash string[] BlockT_Fields = { "kod_dbase" }; // Cash string[] BlockT_FieldsType = { "TEXT" }; // Cash _SQl.SQL_Query("PRAGMA journal_mode=WAL"); _SQl.SQL_Query("pragma synchronous=1"); string value = String.Concat <string>(Access_bd_Fields); DataTable BaseTable = _SQl.ExecuteSQL("SELECT name FROM sqlite_master WHERE type='table' ORDER BY name"); int countTable = BaseTable.Rows.Count; string[] basearray = new string[countTable]; for (int i = 0; i < BaseTable.Rows.Count - 1; i++) { basearray[i] = BaseTable.Rows[i][0].ToString(); } for (int itbl = 0; itbl < baseColName.Length; itbl++) { string fieldsname = baseColName[itbl].ToString(); int searchFields = Array.BinarySearch(basearray, fieldsname); if (searchFields >= 0) { DataTable BaseTableColumnsFields = _SQl.ExecuteSQL("pragma table_info(" + baseColName[itbl].ToString() + ")"); string[] baseColumns = new string[BaseTableColumnsFields.Rows.Count]; for (int icol = 0; icol < BaseTableColumnsFields.Rows.Count; icol++) { baseColumns[icol] = BaseTableColumnsFields.Rows[icol][1].ToString(); } string ArrayName = baseColName[itbl].ToString() + "_Fields"; int i = 0; switch (ArrayName) { case "Access_bd_Fields": foreach (string ColumnsName in Access_bd_Fields) { int searchColumns = Array.IndexOf(baseColumns, ColumnsName); if (searchColumns < 0) { _SQl.SQL_Query("ALTER TABLE " + ArrayName.Remove(ArrayName.IndexOf("_Fields")) + " ADD COLUMN " + ColumnsName + " " + Access_bd_FieldsType[i].ToString() + ""); } i++; } i = 0; break; case "Brand_Fields": foreach (string ColumnsName in Brand_Fields) { int searchColumns = Array.IndexOf(baseColumns, ColumnsName); if (searchColumns < 0) { _SQl.SQL_Query("ALTER TABLE " + ArrayName.Remove(ArrayName.IndexOf("_Fields")) + " ADD COLUMN " + ColumnsName + " " + Brand_FieldsType[i].ToString() + ""); } i++; } i = 0; break; case "BlockT_Fields": foreach (string ColumnsName in BlockT_Fields) { int searchColumns = Array.IndexOf(baseColumns, ColumnsName); if (searchColumns < 0) { _SQl.SQL_Query("ALTER TABLE " + ArrayName.Remove(ArrayName.IndexOf("_Fields")) + " ADD COLUMN " + ColumnsName + " " + BlockT_FieldsType[i].ToString() + ""); } i++; } i = 0; break; case "Cash_Fields": foreach (string ColumnsName in Cash_Fields) { int searchColumns = Array.IndexOf(baseColumns, ColumnsName); if (searchColumns < 0) { _SQl.SQL_Query("ALTER TABLE " + ArrayName.Remove(ArrayName.IndexOf("_Fields")) + " ADD COLUMN " + ColumnsName + " " + Cash_FieldsType[i].ToString() + ""); } i++; } i = 0; break; case "ClassT_Fields": foreach (string ColumnsName in ClassT_Fields) { int searchColumns = Array.IndexOf(baseColumns, ColumnsName); if (searchColumns < 0) { _SQl.SQL_Query("ALTER TABLE " + ArrayName.Remove(ArrayName.IndexOf("_Fields")) + " ADD COLUMN " + ColumnsName + " " + ClassT_FieldsType[i].ToString() + ""); } i++; } i = 0; break; case "Dbase_Fields": foreach (string ColumnsName in Dbase_Fields) { int searchColumns = Array.IndexOf(baseColumns, ColumnsName); if (searchColumns < 0) { _SQl.SQL_Query("ALTER TABLE " + ArrayName.Remove(ArrayName.IndexOf("_Fields")) + " ADD COLUMN " + ColumnsName + " " + Dbase_FieldsType[i].ToString() + ""); } i++; } i = 0; break; case "Groupt_Fields": foreach (string ColumnsName in Groupt_Fields) { int searchColumns = Array.IndexOf(baseColumns, ColumnsName); if (searchColumns < 0) { _SQl.SQL_Query("ALTER TABLE " + ArrayName.Remove(ArrayName.IndexOf("_Fields")) + " ADD COLUMN " + ColumnsName + " " + Groupt_FieldsType[i].ToString() + ""); } i++; } i = 0; break; case "Incoming_Fields": foreach (string ColumnsName in Incoming_Fields) { int searchColumns = Array.IndexOf(baseColumns, ColumnsName); if (searchColumns < 0) { _SQl.SQL_Query("ALTER TABLE " + ArrayName.Remove(ArrayName.IndexOf("_Fields")) + " ADD COLUMN " + ColumnsName + " " + Incoming_FieldsType[i].ToString() + ""); } i++; } i = 0; break; case "Outgoing_Fields": foreach (string ColumnsName in Outgoing_Fields) { int searchColumns = Array.IndexOf(baseColumns, ColumnsName); if (searchColumns < 0) { _SQl.SQL_Query("ALTER TABLE " + ArrayName.Remove(ArrayName.IndexOf("_Fields")) + " ADD COLUMN " + ColumnsName + " " + Outgoing_FieldsType[i].ToString() + ""); } i++; } i = 0; break; case "Pereocenka_Fields": foreach (string ColumnsName in Pereocenka_Fields) { int searchColumns = Array.IndexOf(baseColumns, ColumnsName); if (searchColumns < 0) { _SQl.SQL_Query("alter TABLE " + ArrayName.Remove(ArrayName.IndexOf("_Fields")) + " ADD COLUMN " + ColumnsName + " " + Pereocenka_FieldsType[i].ToString() + ""); } i++; } i = 0; break; case "Sales_Fields": foreach (string ColumnsName in Sales_Fields) { int searchColumns = Array.IndexOf(baseColumns, ColumnsName); if (searchColumns < 0) { _SQl.SQL_Query("ALTER TABLE " + ArrayName.Remove(ArrayName.IndexOf("_Fields")) + " ADD COLUMN " + ColumnsName + " " + Sales_FieldsType[i].ToString() + ""); } i++; } i = 0; break; case "Source_Fields": foreach (string ColumnsName in Source_Fields) { int searchColumns = Array.IndexOf(baseColumns, ColumnsName); if (searchColumns < 0) { _SQl.SQL_Query("ALTER TABLE " + ArrayName.Remove(ArrayName.IndexOf("_Fields")) + " ADD COLUMN " + ColumnsName + " " + Source_FieldsType[i].ToString() + " NOT NULL default(0)"); } i++; } i = 0; break; case "Suppliers_Fields": foreach (string ColumnsName in Suppliers_Fields) { int searchColumns = Array.IndexOf(baseColumns, ColumnsName); if (searchColumns < 0) { _SQl.SQL_Query("ALTER TABLE " + ArrayName.Remove(ArrayName.IndexOf("_Fields")) + " ADD COLUMN " + ColumnsName + " " + Suppliers_FieldsType[i].ToString() + ""); } i++; } i = 0; break; case "Users_Fields": foreach (string ColumnsName in Users_Fields) { int searchColumns = Array.IndexOf(baseColumns, ColumnsName); if (searchColumns < 0) { _SQl.SQL_Query("ALTER TABLE " + ArrayName.Remove(ArrayName.IndexOf("_Fields")) + " ADD COLUMN " + ColumnsName + " " + Users_FieldsType[i].ToString() + ""); } i++; } i = 0; break; default: Console.WriteLine("Такой язык я не знаю"); break; } } else { string createtable = ""; string ArrayName = fieldsname + "_Fields"; int i = 0; string columnsType = ""; switch (ArrayName) { case "Access_bd_Fields": foreach (string ColumnsName in Access_bd_Fields) { if (i != Access_bd_Fields.Length - 1) { columnsType = columnsType + ColumnsName + " " + Access_bd_FieldsType[i].ToString() + ","; } else { columnsType = columnsType + ColumnsName + " " + Access_bd_FieldsType[i].ToString(); } i++; } createtable = "CREATE TABLE " + fieldsname + " (" + columnsType + ")"; _SQl.SQL_Query(createtable); columnsType = ""; createtable = ""; i = 0; break; case "Brand_Fields": foreach (string ColumnsName in Brand_Fields) { if (i != Brand_Fields.Length - 1) { columnsType = columnsType + ColumnsName + " " + Brand_FieldsType[i].ToString() + ","; } else { columnsType = columnsType + ColumnsName + " " + Brand_FieldsType[i].ToString(); } i++; } createtable = "CREATE TABLE " + fieldsname + " (" + columnsType + ")"; _SQl.SQL_Query(createtable); columnsType = ""; createtable = ""; i = 0; break; case "BlockT_Fields": foreach (string ColumnsName in BlockT_Fields) { if (i != BlockT_Fields.Length - 1) { columnsType = columnsType + ColumnsName + " " + BlockT_FieldsType[i].ToString() + ","; } else { columnsType = columnsType + ColumnsName + " " + BlockT_FieldsType[i].ToString(); } i++; } createtable = "CREATE TABLE " + fieldsname + " (" + columnsType + ")"; _SQl.SQL_Query(createtable); columnsType = ""; createtable = ""; i = 0; break; case "Cash_Fields": foreach (string ColumnsName in Cash_Fields) { if (i != Cash_Fields.Length - 1) { columnsType = columnsType + ColumnsName + " " + Cash_FieldsType[i].ToString() + ","; } else { columnsType = columnsType + ColumnsName + " " + Cash_FieldsType[i].ToString(); } i++; } createtable = "CREATE TABLE " + fieldsname + " (" + columnsType + ")"; _SQl.SQL_Query(createtable); columnsType = ""; createtable = ""; i = 0; break; case "ClassT_Fields": foreach (string ColumnsName in ClassT_Fields) { if (i != ClassT_Fields.Length - 1) { columnsType = columnsType + ColumnsName + " " + ClassT_FieldsType[i].ToString() + ","; } else { columnsType = columnsType + ColumnsName + " " + ClassT_FieldsType[i].ToString(); } i++; } createtable = "CREATE TABLE " + fieldsname + " (" + columnsType + ")"; _SQl.SQL_Query(createtable); columnsType = ""; createtable = ""; i = 0; break; case "Dbase_Fields": foreach (string ColumnsName in Dbase_Fields) { if (i != Dbase_Fields.Length - 1) { columnsType = columnsType + ColumnsName + " " + Dbase_FieldsType[i].ToString() + ","; } else { columnsType = columnsType + ColumnsName + " " + Dbase_FieldsType[i].ToString(); } i++; } createtable = "CREATE TABLE " + fieldsname + " (" + columnsType + ")"; _SQl.SQL_Query(createtable); columnsType = ""; createtable = ""; i = 0; break; case "Groupt_Fields": foreach (string ColumnsName in Groupt_Fields) { if (i != Groupt_Fields.Length - 1) { columnsType = columnsType + ColumnsName + " " + Groupt_FieldsType[i].ToString() + ","; } else { columnsType = columnsType + ColumnsName + " " + Groupt_FieldsType[i].ToString(); } i++; } createtable = "CREATE TABLE " + fieldsname + " (" + columnsType + ")"; _SQl.SQL_Query(createtable); columnsType = ""; createtable = ""; i = 0; break; case "Incoming_Fields": foreach (string ColumnsName in Incoming_Fields) { if (i != Incoming_Fields.Length - 1) { columnsType = columnsType + ColumnsName + " " + Incoming_FieldsType[i].ToString() + ","; } else { columnsType = columnsType + ColumnsName + " " + Incoming_FieldsType[i].ToString(); } i++; } createtable = "CREATE TABLE " + fieldsname + " (" + columnsType + ")"; _SQl.SQL_Query(createtable); columnsType = ""; createtable = ""; i = 0; break; case "Outgoing_Fields": foreach (string ColumnsName in Outgoing_Fields) { if (i != Outgoing_Fields.Length - 1) { columnsType = columnsType + ColumnsName + " " + Outgoing_FieldsType[i].ToString() + ","; } else { columnsType = columnsType + ColumnsName + " " + Outgoing_FieldsType[i].ToString(); } i++; } createtable = "CREATE TABLE " + fieldsname + " (" + columnsType + ")"; _SQl.SQL_Query(createtable); columnsType = ""; createtable = ""; i = 0; break; case "Pereocenka_Fields": foreach (string ColumnsName in Pereocenka_Fields) { if (i != Pereocenka_Fields.Length - 1) { columnsType = columnsType + ColumnsName + " " + Pereocenka_FieldsType[i].ToString() + ","; } else { columnsType = columnsType + ColumnsName + " " + Pereocenka_FieldsType[i].ToString(); } i++; } createtable = "CREATE TABLE " + fieldsname + " (" + columnsType + ")"; _SQl.SQL_Query(createtable); columnsType = ""; createtable = ""; i = 0; break; case "Sales_Fields": foreach (string ColumnsName in Sales_Fields) { if (i != Sales_Fields.Length - 1) { columnsType = columnsType + ColumnsName + " " + Sales_FieldsType[i].ToString() + ","; } else { columnsType = columnsType + ColumnsName + " " + Sales_FieldsType[i].ToString(); } i++; } createtable = "CREATE TABLE " + fieldsname + " (" + columnsType + ")"; _SQl.SQL_Query(createtable); columnsType = ""; createtable = ""; i = 0; break; case "Source_Fields": foreach (string ColumnsName in Source_Fields) { if (i != Source_Fields.Length - 1) { columnsType = columnsType + ColumnsName + " " + Source_FieldsType[i].ToString() + " NOT NULL default(0),"; } else { columnsType = columnsType + ColumnsName + " " + Source_FieldsType[i].ToString() + " NOT NULL default(0)"; } i++; } createtable = "CREATE TABLE " + fieldsname + " (" + columnsType + ")"; _SQl.SQL_Query(createtable); columnsType = ""; createtable = ""; i = 0; break; case "Suppliers_Fields": foreach (string ColumnsName in Suppliers_Fields) { if (i != Suppliers_Fields.Length - 1) { columnsType = columnsType + ColumnsName + " " + Suppliers_FieldsType[i].ToString() + ","; } else { columnsType = columnsType + ColumnsName + " " + Suppliers_FieldsType[i].ToString(); } i++; } createtable = "CREATE TABLE " + fieldsname + " (" + columnsType + ")"; _SQl.SQL_Query(createtable); columnsType = ""; createtable = ""; i = 0; break; case "Users_Fields": foreach (string ColumnsName in Users_Fields) { if (i != Users_Fields.Length - 1) { columnsType = columnsType + ColumnsName + " " + Users_FieldsType[i].ToString() + ","; } else { columnsType = columnsType + ColumnsName + " " + Users_FieldsType[i].ToString(); } i++; } createtable = "CREATE TABLE " + fieldsname + " (" + columnsType + ")"; _SQl.SQL_Query(createtable); columnsType = ""; createtable = ""; i = 0; break; default: //Console.WriteLine("Такой язык я не знаю"); break; } } } }
private void load_source() { string Sqlload_source = "select * from Source"; DataTable load_sourceTable = _SQl.ExecuteSQL(Sqlload_source); if (load_sourceTable.Rows.Count == 0) { MessageBox.Show("Заполните первичные данные, в меню ''Основные настройки''!", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } //chek_load = Convert.ToInt32(load_sourceTable.Rows[0][0].ToString()); //pref_kod = load_sourceTable.Rows[0][1].ToString(); //pref_dok_prihod = load_sourceTable.Rows[0][2].ToString(); //pref_dok_rashod = load_sourceTable.Rows[0][3].ToString(); //ean_mag = load_sourceTable.Rows[0][4].ToString(); //kod_mag = Convert.ToInt32(load_sourceTable.Rows[0][6].ToString()); //number_dok_rashod = Convert.ToInt32(load_sourceTable.Rows[0][7].ToString()); //number_dok_prihod = Convert.ToInt32(load_sourceTable.Rows[0][8].ToString()); //min_margin = Convert.ToDouble(load_sourceTable.Rows[0][9].ToString()); urliconame = load_sourceTable.Rows[0][5].ToString(); ogrn = load_sourceTable.Rows[0][10].ToString(); inn = load_sourceTable.Rows[0][11].ToString(); city = load_sourceTable.Rows[0][23].ToString(); indexcity = load_sourceTable.Rows[0][12].ToString(); street = load_sourceTable.Rows[0][13].ToString(); dom = load_sourceTable.Rows[0][14].ToString(); stroenie = load_sourceTable.Rows[0][15].ToString(); litera = load_sourceTable.Rows[0][16].ToString(); NamePrinterChek = load_sourceTable.Rows[0][21].ToString(); NamePrinterDok = load_sourceTable.Rows[0][22].ToString(); if (indexcity != "") { fullAdress = indexcity; } if (city != "") { fullAdress += ",г. " + city; } if (street != "") { fullAdress += "," + street; } if (dom != "") { fullAdress += "," + dom; } if (stroenie != "") { fullAdress += "," + stroenie; } if (litera != "") { fullAdress += "," + litera; } SMTPMail = load_sourceTable.Rows[0][24].ToString(); LoginMail = load_sourceTable.Rows[0][25].ToString(); PassMail = load_sourceTable.Rows[0][26].ToString(); ToMail = load_sourceTable.Rows[0][27].ToString(); SubMail = load_sourceTable.Rows[0][28].ToString(); BodyMail = load_sourceTable.Rows[0][29].ToString(); Attach = load_sourceTable.Rows[0][30].ToString(); ServerIP = load_sourceTable.Rows[0][32].ToString(); ServerPort = load_sourceTable.Rows[0][33].ToString(); ClientIP = load_sourceTable.Rows[0][34].ToString(); ClientPort = load_sourceTable.Rows[0][35].ToString(); if (load_sourceTable.Rows[0][31].ToString() == "") { TimerMail = 0; } else { TimerMail = Convert.ToInt16(load_sourceTable.Rows[0][31].ToString()); } if (TimerMail != 0) { TimerSentMail.Interval = (TimerMail * 60) * 1000; TimerSentMail.Enabled = true; } }