コード例 #1
0
ファイル: ClientView.cs プロジェクト: Kiselb/bps
        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 = "";
        }
コード例 #2
0
ファイル: ClientView.cs プロジェクト: Kiselb/bps
 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);
         }
     }
 }