public AddClient(DataView dv, DataView dvRate) { // // Required for Windows Form Designer support // this.dvGroups = dv; InitializeComponent(); BPS.App.SetDataGridTableStyle(this.dataGridTableStyle1); BPS.App.SetDataGridTableStyle(this.dataGridTableStyle2); BPS.App.SetDataGridTableStyle(this.dataGridTableStyle3); try { this.dataGrid1.DataSource = dvRate; this.dvGroups.RowFilter = "(IsInner=false and IsSpecial=false)"; this.cmbGroup.DataSource = this.dvGroups; //dv.Table;// this.dsGroups1.Tables[0]; this.cmbGroup.ValueMember = "ClientGroupID"; this.cmbGroup.DisplayMember = "ClientGroupName"; if (this.cmbGroup.Items.Count > 0) { this.cmbGroup.SelectedIndex = 0; } this.tabControl1.Controls.Remove(this.tabPage2); this.tabControl1.Controls.Remove(this.tabPage3); } catch (Exception ex) { MsgBoxX.Show(ex.Message, "BPS", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } // // TODO: Add any constructor code after InitializeComponent call // }
public static bool ExecuteNonQuery(System.Data.OleDb.OleDbCommand sqlCmd) { bool bCloseConnection = false; try { sqlCmd.Connection = Connection; if (Transaction != null) { sqlCmd.Transaction = Transaction; } Cursor.Current = Cursors.WaitCursor; if (sqlCmd.Connection.State == ConnectionState.Closed) { sqlCmd.Connection.Open(); bCloseConnection = true; } sqlCmd.ExecuteNonQuery(); return(true); } catch (Exception ex) { Cursor.Current = Cursors.Default; MsgBoxX.Show(ex.Message); return(false); } finally { Cursor.Current = Cursors.Default; if (bCloseConnection) { sqlCmd.Connection.Close(); } } }
public static bool ExecSql(System.Data.SqlClient.SqlCommand sqlCmd) { bool bCloseConnection = false; try { Cursor.Current = Cursors.WaitCursor; if (sqlCmd.Connection.State == ConnectionState.Closed) { sqlCmd.Connection.Open(); bCloseConnection = true; } sqlCmd.ExecuteNonQuery(); return(true); } catch (Exception ex) { Cursor.Current = Cursors.Default; MsgBoxX.Show(ex.Message, "BPS", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return(false); } finally { Cursor.Current = Cursors.Default; if (bCloseConnection) { sqlCmd.Connection.Close(); } } }
public void SetCurrencyMainRate(string szCurrencyID, double dRate) { //MessageBox.Show("OK!"); try { this.sqlCmdSetRate.Parameters["@sCurrencyID"].Value = szCurrencyID; this.sqlCmdSetRate.Parameters["@fRate"].Value = dRate; if (this.sqlCmdSetRate.Connection.State != ConnectionState.Open) { this.sqlCmdSetRate.Connection.Open(); } this.sqlCmdSetRate.ExecuteNonQuery(); this.Fill(); } catch (Exception ex) { MsgBoxX.Show(ex.Message, "BPS", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } finally { if (this.sqlCmdSetRate.Connection.State != ConnectionState.Closed) { this.sqlCmdSetRate.Connection.Close(); } } }
private bool validateCurr() { this.tbCurrID.Text = this.tbCurrID.Text.Trim(); if (this.tbCurrID.Text.Length == 0) { MsgBoxX.Show("Заполните поле КОД", "BPS", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); this.tbCurrID.Focus(); return(false); } else { if (drowCurrency.RowState == DataRowState.Detached && drowCurrency.Table.Select("CurrencyID=\'" + this.tbCurrID.Text + "\'").Length != 0) { MsgBoxX.Show("Валюта с таким кодом уже существует в системе"); this.tbCurrID.Focus(); return(false); } } this.tbCurrName.Text = this.tbCurrName.Text.Trim(); if (this.tbCurrName.Text.Length == 0) { MsgBoxX.Show("Заполните поле НАЗВАНИЕ", "BPS", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); this.tbCurrName.Focus(); return(false); } if (this.tbvRate.dValue <= 0) { MsgBoxX.Show("Заполните поле КУРС", "BPS", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); this.tbvRate.Focus(); return(false); } return(true); }
private void deleteClient() { if (!App.AllowClientsDirChange) { return; } if (this.dataView1.Count > 0) { try { BindingManagerBase bm = (BindingManagerBase)this.BindingContext[this.dataView1]; BPS.BLL.Clients.DataSets.dsClients.ClientsRow rw = (BPS.BLL.Clients.DataSets.dsClients.ClientsRow)((DataRowView)bm.Current).Row; if (MsgBoxX.Show("Вы действительно хотите удалить клиента " + rw.ClientName + "?", "BPS", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { //((DataRowView)bm.Current).Row.Delete(); rw.Delete(); UpdateDs(false); } } catch (Exception ex) { MsgBoxX.Show(ex.Message, "BPS", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } } }
private void addingGroup(int iMode) { AddGroup ag = new AddGroup(); if (iMode == -1) { ag.tbName.Text = this.cmbGroup.Text; } ag.ShowDialog(); if (ag.DialogResult == DialogResult.OK) { try { BPS.BLL.Clients.DataSets.dsGroups.ClientsGroupsRow rw = (BPS.BLL.Clients.DataSets.dsGroups.ClientsGroupsRow) this.dvGroups.Table.NewRow(); //((BPS.Clients.dsGroups.ClientsGroupsDataTable)this.cmbGroup.DataSource).NewRow(); rw.ClientGroupName = ag.tbName.Text; rw.ClientGroupRemarks = ag.tbRemarks.Text; rw.IsInner = false; rw.IsSpecial = false; this.dvGroups.Table.Rows.Add((DataRow)rw); //((Clients.dsGroups.ClientsGroupsDataTable)this.cmbGroup.DataSource).AddClientsGroupsRow(rw); AddGroup(); } catch (Exception ex) { MsgBoxX.Show(ex.Message, "BPS", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } } }
private bool validateGroup() { this.trimGroup(); if (this.tbName.Text.Length == 0) { MsgBoxX.Show("Заполните поле НАЗВАНИЕ", "BPS", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return(false); } return(true); }
private bool validateBank() { this.tbName.Text = AM_Lib.TrimSpec.Trim(this.tbName.Text); if (this.tbName.Text.Length == 0) { MsgBoxX.Show("Заполните поле НАЗВАНИЕ", "BPS", MessageBoxButtons.OK, MessageBoxIcon.Warning); this.tbName.Focus(); return(false); } if (this.cmbCity.SelectedIndex == -1) { MsgBoxX.Show("Правильно выберите ГОРОД", "BPS", MessageBoxButtons.OK, MessageBoxIcon.Warning); this.cmbCity.Focus(); return(false); } if (this.tbBIK.Text.Length == 0) { MsgBoxX.Show("Заполните поле БИК", "BPS", MessageBoxButtons.OK, MessageBoxIcon.Warning); this.tbBIK.Focus(); return(false); } if (this.tbBIK.Text.Length != 9) { MsgBoxX.Show("Поле БИК должно содержать 9 цифр!", "BPS", MessageBoxButtons.OK, MessageBoxIcon.Warning); this.tbBIK.Focus(); return(false); } else { DataRow [] dr = this.drowBank.Table.Select("CodeBIK='" + this.tbBIK.Text + "'"); if (dr.Length > 0 && drowBank.RowState == DataRowState.Detached) { AM_Controls.MsgBoxX.Show("Банк с БИК " + this.tbBIK.Text + " уже существует", "BPS", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); this.tbBIK.Focus(); return(false); } } if (this.tbKAccount.Text.Length == 0) { MsgBoxX.Show("Заполните поле КОР. СЧЁТ", "BPS", MessageBoxButtons.OK, MessageBoxIcon.Warning); this.tbKAccount.Focus(); return(false); } if (this.tbKAccount.Text.Length != 20) { MsgBoxX.Show("Поле КОР. СЧЁТ должно содержать 20 цифр!", "BPS", MessageBoxButtons.OK, MessageBoxIcon.Warning); this.tbKAccount.Focus(); return(false); } return(true); }
private void addClient() { if (!App.AllowClientsDirChange) { return; } InterestRates.CreateRateView(); AddClient ac = new AddClient(this.dvGroups, this.dvClientRate); ac.AddGroup += new AddClient.AddGroupEventHandler(addGroup); ac.Text += " [Новый]"; ac.ShowDialog(); if (ac.DialogResult == DialogResult.OK) { try { BPS.BLL.Clients.DataSets.dsClients.ClientsRow newRow = (BPS.BLL.Clients.DataSets.dsClients.ClientsRow) this.dataView1.Table.NewRow(); //this.dsClients1._Table.NewRow(); newRow.ClientName = ac.tbClient.Text; if (ac.tbRemarks.Text.Length > 0) { newRow.ClientRemarks = ac.tbRemarks.Text; } else { newRow.ClientRemarks = "-"; } newRow.ClientGroupID = Convert.ToInt32(ac.cmbGroup.SelectedValue); newRow.ClientGroupName = ac.cmbGroup.Text; if (ac.tbPassw.Text.Length > 0) { string szPwd = ac.tbPassw.Text; byte [] bPwd = new Byte[szPwd.Length]; for (int i = 0; i < szPwd.Length; i++) { bPwd[i] = Convert.ToByte(szPwd[i]); } MD5 md5 = new MD5CryptoServiceProvider(); byte [] resPwd = md5.ComputeHash(bPwd); newRow.Password = BitConverter.ToString(resPwd); } this.dataView1.Table.Rows.Add((DataRow)newRow); UpdateDs(true); InterestRates.SaveChangesRates(newRow); } catch (Exception ex) { MsgBoxX.Show(ex.Message, "BPS", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } } this.dvGroups.RowFilter = ""; }
private void deleteBank() { if (this.dvBanks.Count > 0) { BindingManagerBase bm = (BindingManagerBase)this.BindingContext[this.dvBanks]; BPS.BLL.Bank.DataSets.dsBanks.BanksRow rw = (BPS.BLL.Bank.DataSets.dsBanks.BanksRow)((DataRowView)bm.Current).Row; if (MsgBoxX.Show("Вы действительно хотите удалить банк " + rw.BankName + "?", "BPS", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { ((DataRowView)bm.Current).Delete(); bllBank.Update(); } } }
private void editClient() { if (!App.AllowClientsDirChange) { return; } if (this.dataView1.Count > 0) { BindingManagerBase bm = (BindingManagerBase)this.BindingContext[this.dataView1]; BPS.BLL.Clients.DataSets.dsClients.ClientsRow rw = (BPS.BLL.Clients.DataSets.dsClients.ClientsRow)((DataRowView)bm.Current).Row; try { FillDSOrgsClients(rw.ClientID); AddClient ec = new AddClient(rw, this.dvGroups, this.dvClientRate, this.dsOrgsClients1); ec.Text += " [Редактирование]"; ec.AddGroup += new AddClient.AddGroupEventHandler(addGroup); ec.ShowDialog(); if (ec.DialogResult == DialogResult.OK) { rw.ClientGroupID = Convert.ToInt32(ec.cmbGroup.SelectedValue); rw.ClientName = ec.tbClient.Text; rw.ClientRemarks = ec.tbRemarks.Text; rw.ClientGroupName = ec.cmbGroup.Text; //rw.IsSpecial = ec.cbSpecial.Checked; if (ec.tbPassw.Text.Length > 0) { string szPwd = ec.tbPassw.Text; byte [] bPwd = new Byte[szPwd.Length]; for (int i = 0; i < szPwd.Length; i++) { bPwd[i] = Convert.ToByte(szPwd[i]); } MD5 md5 = new MD5CryptoServiceProvider(); byte [] resPwd = md5.ComputeHash(bPwd); rw.Password = BitConverter.ToString(resPwd); } UpdateDs(false); InterestRates.SaveChangesRates(rw); UpdateDSOrgsClients(); } else { this.dsInterestRate1.RejectChanges(); } } catch (Exception ex) { MsgBoxX.Show(ex.Message, "BPS", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } } }
public int AddCity(string sCityName) { if (this.dsCities1.Cities.Select("CityName=\'" + sCityName + "\'").Length != 0) { MsgBoxX.Show("Такой город уже существует в справочнике", "BPS", MessageBoxButtons.OK, MessageBoxIcon.Warning); return(-1); } DataSets.dsCities.CitiesRow rw = this.dsCities1.Cities.NewCitiesRow(); rw.CityName = sCityName; this.dsCities1.Cities.AddCitiesRow(rw); this.Update(); return(UpdatedRowID); }
private void Refill() { try { if (AskConfirmStoring()) { this.sqlDataAdapter1.Fill(this.dsBankAccountsStates1.Orgs); } } catch (Exception ex) { MsgBoxX.Show("При чтении данных произошла ошибка: " + ex.Message.ToString(), "BPS", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }
private void Refill() { try { if (AskConfirmStoring()) { this.sqlDataAdapter1.Fill(this.dsClientsBalances1.Accounts); } this.dsClientsGroupsBalances1.Accounts.Clear(); this.sqlDataAdapter2.Fill(this.dsClientsGroupsBalances1.Accounts); } catch (Exception ex) { MsgBoxX.Show("При чтении данных произошла ошибка: " + ex.Message.ToString(), "BPS", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }
private void AddCity() { BPS.Forms.City.CityEdit CityEditForm = new BPS.Forms.City.CityEdit(this.bllCity, this.cmbCity.Text); if (CityEditForm.ShowDialog() == DialogResult.OK) { if ( this.bllCity.DataSet.Cities.Select("CityName=\'" + CityEditForm.strCityName + "\'").Length != 0) { MsgBoxX.Show("Такой город уже существует в справочнике", "BPS", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } BPS.BLL.City.DataSets.dsCities.CitiesRow rw = this.bllCity.DataSet.Cities.NewCitiesRow(); rw.CityName = CityEditForm.strCityName; this.bllCity.DataSet.Cities.AddCitiesRow(rw); this.bllCity.Update(); } }
public static System.Data.OleDb.OleDbDataReader ExecuteReader(System.Data.OleDb.OleDbCommand sqlCmd) { try { sqlCmd.Connection = Connection; if (sqlCmd.Connection.State == ConnectionState.Closed) { sqlCmd.Connection.Open(); } return(sqlCmd.ExecuteReader(CommandBehavior.CloseConnection)); } catch (Exception ex) { MsgBoxX.Show(ex.Message); return(null); } }
public AddClient(BPS.BLL.Clients.DataSets.dsClients.ClientsRow dr, DataView dv, DataView dvRate, BPS.BLL.Clients.DataSets.dsOrgsClients dsOrgsClientsEd) { this.dvGroups = dv; rw = dr; InitializeComponent(); BPS.App.SetDataGridTableStyle(this.dataGridTableStyle1); BPS.App.SetDataGridTableStyle(this.dataGridTableStyle2); BPS.App.SetDataGridTableStyle(this.dataGridTableStyle3); try { //this.sqlDataAdapter2.Fill(this.dsGroups1); this.cmbGroup.DataSource = this.dvGroups; //dv.Table;//this.dsGroups1.Tables[0]; this.cmbGroup.ValueMember = "ClientGroupID"; this.cmbGroup.DisplayMember = "ClientGroupName"; this.cmbGroup.SelectedValue = dr.ClientGroupID; //["ClientGroupID"]; this.tbClient.Text = dr.ClientName; //["ClientName"].ToString(); this.tbRemarks.Text = dr.ClientRemarks; //["ClientRemarks"].ToString(); //this.cbSpecial.Checked = dr.IsSpecial; this.dataGrid1.DataSource = dvRate; if (dr.IsInner || dr.IsSpecial) { this.cmbGroup.Enabled = false; } else { dv.RowFilter = "IsInner=false and IsSpecial=false"; } // this.sqlSelectClientsOrgs.Parameters["@ClientID"].Value = dr.ClientID; // this.sqldaSelOrgsClients.Fill(this.dsOrgsClients1); this.dsOrgsClients1 = dsOrgsClientsEd; this.dvSend.Table = this.dsOrgsClients1.OrgsClients; this.dvSend.RowFilter = "Direction=1 and IsRemoved=0"; this.dvReceive.Table = this.dsOrgsClients1.OrgsClients; this.dvReceive.RowFilter = "Direction=0 and IsRemoved=0"; } catch (Exception ex) { MsgBoxX.Show(ex.Message, "BPS", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } if (dr.IsInner || dr.IsSpecial) { this.cmbGroup.Enabled = false; } }
private void deleteCurr() { if (this.dataView1.Count > 0) { try { BindingManagerBase bm = (BindingManagerBase)this.BindingContext[this.dataView1]; BPS.BLL.Currency.DataSets.dsCurr.CurrenciesRow rw = (BPS.BLL.Currency.DataSets.dsCurr.CurrenciesRow)((DataRowView)bm.Current).Row; if (MsgBoxX.Show("Вы действительно хотите удалить валюту " + rw.CurrencyName + "?", "BPS", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { ((DataRowView)bm.Current).Delete(); bllCurrency.Update(); } } catch (Exception ex) { MsgBoxX.Show(ex.Message, "BPS", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } } }
private void deleteOrg() { if (!App.AllowOrgDirChange) { return; } if (this.dataView1.Count > 0) { BindingManagerBase bm = (BindingManagerBase)this.BindingContext[this.dataView1]; BLL.Orgs.DataSets.dsOrgs.OrgsRow rw = (BLL.Orgs.DataSets.dsOrgs.OrgsRow)((DataRowView)bm.Current).Row; if (MsgBoxX.Show("Вы действительно хотите удалить организацию " + rw.OrgName + "?", "BPS", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { ((DataRowView)bm.Current).Delete(); if (!bllOrgs.Update()) { bllOrgs.DataSet.RejectChanges(); } } } }
public static bool ExecuteNonQuery(System.Data.OleDb.OleDbCommand sqlCmd, AM_Lib.dbParam[] sqlParam) { for (int i = 0; i < sqlParam.Length; i++) { sqlCmd.Parameters.Add(sqlParam[i].Name, sqlParam[i].Type); sqlCmd.Parameters[sqlParam[i].Name].Value = sqlParam[i].Value; } bool bCloseConnection = false; try { sqlCmd.Connection = Connection; if (Transaction != null) { sqlCmd.Transaction = Transaction; } Cursor.Current = Cursors.WaitCursor; if (sqlCmd.Connection.State == ConnectionState.Closed) { sqlCmd.Connection.Open(); bCloseConnection = true; } sqlCmd.ExecuteNonQuery(); return(true); } catch (Exception ex) { Cursor.Current = Cursors.Default; MsgBoxX.Show(ex.Message); return(false); } finally { Cursor.Current = Cursors.Default; if (bCloseConnection) { sqlCmd.Connection.Close(); } } }
private void SetCurrencyRate() { if (this.dataView1.Count > 0) { try { string szCurrencyID = ""; double dCurrencyRate = 0; double dCurrencyRateOld = 0; BindingManagerBase bm = (BindingManagerBase)this.BindingContext[this.dataView1]; BPS.BLL.Currency.DataSets.dsCurr.CurrenciesRow rw = (BPS.BLL.Currency.DataSets.dsCurr.CurrenciesRow)((DataRowView)bm.Current).Row; szCurrencyID = rw.CurrencyID; dCurrencyRateOld = rw.CurrencyRate; SetCurrencyRate dlg = new SetCurrencyRate(); dlg.Text = dlg.Text + " " + szCurrencyID; if (dlg.ShowDialog() == DialogResult.OK) { dCurrencyRate = dlg.tbvNewRate.dValue; if ((Math.Abs(dCurrencyRateOld - dCurrencyRate) / dCurrencyRateOld) > 0.05) { if (DialogResult.No == MessageBox.Show("Изменение Курса более чем на 5%. Продолжить?", "BPS", MessageBoxButtons.YesNo, MessageBoxIcon.Warning)) { return; } } bllCurrency.SetCurrencyMainRate(szCurrencyID, dCurrencyRate); } this.dataGrid1.CurrentRowIndex = 0; } catch (Exception ex) { MsgBoxX.Show(ex.Message, "BPS", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } } }
public static object ExecuteScalar(System.Data.OleDb.OleDbCommand sqlCmd) { try { sqlCmd.Connection = Connection; if (sqlCmd.Connection.State == ConnectionState.Closed) { sqlCmd.Connection.Open(); } return(sqlCmd.ExecuteScalar()); } catch (Exception ex) { MsgBoxX.Show(ex.Message); return(null); } finally { Cursor.Current = Cursors.Default; sqlCmd.Connection.Close(); } }
private bool validateClient() { this.trimClient(); if (this.tbClient.Text.Length == 0) { MsgBoxX.Show("Заполните поле ИМЯ КЛИЕНТА", "BPS", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); this.tbClient.Focus(); return(false); } if (this.cmbGroup.SelectedIndex == -1) { MsgBoxX.Show("Задайте ГРУППУ", "BPS", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); this.cmbGroup.Focus(); return(false); } if ((this.tbPassw.Text.Length > 0) && (this.tbPassw.Text != this.tbConfirmPassw.Text)) { MsgBoxX.Show("Неправильно введён подтверждающий пароль клиента. Введите подтверждение пароля заново.", "BPS", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); this.tbConfirmPassw.Focus(); return(false); } return(true); }