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); } } }
public void createRateView(BPS.BLL.Clients.DataSets.dsClients.ClientsRow rwC) { this.dsInterestRate1.InterestRate.Clear(); for (int i = 0; i < this.dsReqTypes1.ClientsRequestTypes.Count; i++) { BPS.BLL.ClientRequest.DataSets.dsReqTypes.ClientsRequestTypesRow rw = DSReqTypes.ClientsRequestTypes[i]; BLL.Clients.DataSets.dsInterestRate.InterestRateRow dr = this.dsInterestRate1.InterestRate.NewInterestRateRow(); dr.ReqType = rw.RequestTypeID; dr.ReqTypeName = rw.RequestTypeName; DataRow [] drCharge = this.dsInterestRateList1.InterestRates.Select("ClientID=" + rwC.ClientID.ToString() + " and RequestTypeID=" + rw.RequestTypeID.ToString() + " and IsNormal=false"); if (drCharge.Length == 0) { dr.SetRateBlackNull(); } else { dr.RateBlack = (double)drCharge[0]["ServiceCharge"] * 100; } DataRow [] drChargeN = this.dsInterestRateList1.InterestRates.Select("ClientID=" + rwC.ClientID.ToString() + " and RequestTypeID=" + rw.RequestTypeID.ToString() + " and IsNormal=true"); if (drChargeN.Length == 0) { dr.SetRateNormalNull(); } else { dr.RateNormal = (double)drChargeN[0]["ServiceCharge"] * 100; } this.dsInterestRate1.InterestRate.AddInterestRateRow(dr); } this.dsInterestRate1.InterestRate.AcceptChanges(); }
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 ClientView_Load(object sender, System.EventArgs e) { this.menuItem2.Enabled = this.menuItem4.Enabled = this.menuItem3.Enabled = this.toolBarButton1.Enabled = this.toolBarButton2.Enabled = this.toolBarButton4.Enabled = App.AllowClientsDirChange; App.Clone(this.mnuEdit.MenuItems, this.contextMenu1); this.applyFilter(); 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; this.InterestRates.createRateView(rw); } }
private void BindingContextChange(object sender, EventArgs e) { 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 (this.dataView1.Count == 0) { InterestRates.DsInterestRates.Clear(); return; } this.dvRateList.RowFilter = "ClientID = " + rw.ClientID.ToString(); this.InterestRates.createRateView(rw); }
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); } } }
private void bnSelect_Click(object sender, System.EventArgs e) { BindingManagerBase bm = this.BindingContext[this.dvClientList]; if (bm.Position < 0) { return; } BPS.BLL.Clients.DataSets.dsClients.ClientsRow rw = (BPS.BLL.Clients.DataSets.dsClients.ClientsRow)((DataRowView)bm.Current).Row; this.iClientID = rw.ClientID; this.szClientName = rw.ClientName; this.DialogResult = DialogResult.OK; this.Close(); }
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 GroupClients_Load(object sender, System.EventArgs e) { if (!DesignMode) { ((System.ComponentModel.ISupportInitialize)(this.dvGroups)).BeginInit(); base.SettingValueNow = true; this._GroupsTable = App.BPSClients.DsGroups.ClientsGroups.Copy(); ((System.ComponentModel.ISupportInitialize)(this.dvGroups)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.dvMembers)).BeginInit(); base.SettingValueNow = true; this._MembersTable = App.BPSClients.DsClients.Clients.Copy(); ((System.ComponentModel.ISupportInitialize)(this.dvMembers)).EndInit(); base.SettingValueNow = true; this._GroupIDColunmName = "ClientGroupID"; base.SettingValueNow = true; this._GroupNameColumnName = "ClientGroupName"; base.SettingValueNow = true; this._MemberIDColumnName = "ClientID"; base.SettingValueNow = true; this._MemberNameColumnName = "ClientName"; base.SettingValueNow = true; this._MembersGroupColumnName = "ClientGroupID"; this.dvGroups.Sort = "ClientGroupID ASC"; this.dvMembers.Sort = "ClientID ASC"; this.dvGroups.AllowNew = true; AddAllRow(0, false); AddAllRow(-1, true); if (bUsageForFilter) { BPS.BLL.Clients.DataSets.dsClients.ClientsRow rwClient = (BPS.BLL.Clients.DataSets.dsClients.ClientsRow) this.dvMembers.Table.NewRow(); rwClient.ClientID = 0; rwClient.ClientGroupID = -1; rwClient.ClientName = "<Все>"; rwClient.ClientRemarks = "<Все>"; rwClient.ClientGroupName = ""; this.dvMembers.Table.Rows.Add(rwClient); } } this.BehaviourChanged += new AM_Controls.BehaviourChangedEventHandler(this.SetControlsPositions); }
private void btnAddClient_Click(object sender, System.EventArgs e) { BPS.BLL.Clients.coInterestRates InterestRates = new BPS.BLL.Clients.coInterestRates(); InterestRates.FillDSReqType(); System.Data.DataView dvRates = new System.Data.DataView(InterestRates.DsInterestRates.InterestRate); dvRates.AllowDelete = dvRates.AllowNew = false; dvRates.AllowEdit = true; BPS._Forms.Clients.AddClient AddClientForm = new BPS._Forms.Clients.AddClient(base.dvGroups, dvRates); if (this.cmbGroups.SelectedIndex == -1 || this.cmbMembers.SelectedIndex == -1) { AddClientForm.tbClient.Text = this.cmbMembers.Text; AddClientForm.cmbGroup.Text = this.cmbGroups.Text; } AddClientForm.AddGroup += new BPS._Forms.Clients.AddClient.AddGroupEventHandler(AddGroup); AddClientForm.ShowDialog(); if (AddClientForm.DialogResult == DialogResult.OK) { try { BPS.BLL.Clients.DataSets.dsClients.ClientsRow rw = (BPS.BLL.Clients.DataSets.dsClients.ClientsRow) this.dvMembers.Table.NewRow(); rw.ClientGroupID = (int)AddClientForm.cmbGroup.SelectedValue; rw.ClientName = AddClientForm.tbClient.Text; rw.ClientRemarks = AddClientForm.tbRemarks.Text; rw.IsInner = false; rw.IsSpecial = false; rw.Password = AddClientForm.tbPassw.Text; this.dvMembers.Table.Rows.Add(rw); App.BPSClients.UpdateGroups(); App.BPSClients.UpdateClients(); this.cmbGroups.SelectedIndex = this.dvGroups.Find(rw.ClientGroupID); this.cmbMembers.SelectedIndex = this.dvMembers.Find(rw.ClientID); } catch (Exception ex) { AM_Controls.MsgBoxX.Show(ex.Message, "BPS", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } } }
public void SaveChangesRates(BPS.BLL.Clients.DataSets.dsClients.ClientsRow rw) { int iClientID = rw.ClientID; for (int i = 0; i < this.dsInterestRate1.InterestRate.Rows.Count; i++) { BLL.Clients.DataSets.dsInterestRate.InterestRateRow dr = (BLL.Clients.DataSets.dsInterestRate.InterestRateRow) this.dsInterestRate1.InterestRate.Rows[i]; DataRow [] drInterest = this.dsInterestRateList1.InterestRates.Select("ClientID=" + iClientID.ToString() + " and RequestTypeID=" + dr.ReqType.ToString() + " and IsNormal=false"); if (!dr.IsRateBlackNull()) // != Convert.DBNull) { if (drInterest.Length == 0) { BPS.BLL.Clients.DataSets.dsInterestRateList.InterestRatesRow newIntRow = (BPS.BLL.Clients.DataSets.dsInterestRateList.InterestRatesRow) this.dsInterestRateList1.InterestRates.NewRow(); newIntRow.ClientID = iClientID; newIntRow.RequestTypeID = dr.ReqType; newIntRow.IsNormal = false; newIntRow.ServiceCharge = dr.RateBlack / 100; newIntRow.MaxSum = 0; this.dsInterestRateList1.InterestRates.Rows.Add((DataRow)newIntRow); } else { drInterest[0]["ServiceCharge"] = ((double)dr.RateBlack / 100).ToString(); } } else { if (drInterest.Length == 1) { drInterest[0].Delete(); } } DataRow [] drInterestN = this.dsInterestRateList1.InterestRates.Select("ClientID=" + iClientID.ToString() + " and RequestTypeID=" + dr.ReqType.ToString() + " and IsNormal=true"); if (!dr.IsRateNormalNull()) { if (drInterestN.Length == 0) { BPS.BLL.Clients.DataSets.dsInterestRateList.InterestRatesRow newIntRow = (BPS.BLL.Clients.DataSets.dsInterestRateList.InterestRatesRow) this.dsInterestRateList1.InterestRates.NewRow(); newIntRow.ClientID = iClientID; newIntRow.RequestTypeID = dr.ReqType; newIntRow.IsNormal = true; newIntRow.ServiceCharge = dr.RateNormal / 100; newIntRow.MaxSum = 0; this.dsInterestRateList1.InterestRates.Rows.Add((DataRow)newIntRow); } else { drInterestN[0]["ServiceCharge"] = (dr.RateNormal / 100).ToString(); } } else { if (drInterestN.Length == 1) { drInterestN[0].Delete(); } } } UpdateInterestRateList(); }