Ejemplo n.º 1
0
        private void FormAgentRecord_Load(object sender, EventArgs e)
        {
            ControlBindDataSource cbds = new ControlBindDataSource();

            cbds.DataGridViewComboBoxColumnBindDataSource(ProvinceCode, "ProvinceCode", "ProvinceName", "Select * From Province", "Province");
            bsAgentRecord.DataSource  = ar.GetDataTable("Customer", "Where CustomerType = '1' ");
            dgvAgentRecord.DataSource = bsAgentRecord;
        }
Ejemplo n.º 2
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            AgentRecord ar = new AgentRecord();

            if (String.IsNullOrEmpty(txtCustomerName.Text.Trim()))
            {
                MessageBox.Show("代理商名称不许为空!", "软件提示");
                txtCustomerName.Focus();
                return;
            }
            if (String.IsNullOrEmpty(txtJuridicalPerson.Text.Trim()))
            {
                MessageBox.Show("法人不许为空!", "软件提示");
                txtJuridicalPerson.Focus();
                return;
            }
            if (String.IsNullOrEmpty(txtPhoneNumber.Text.Trim()))
            {
                MessageBox.Show("联系电话不许为空!", "软件提示");
                txtPhoneNumber.Focus();
                return;
            }
            if (cbxProvinceCode.SelectedValue == null)
            {
                MessageBox.Show("所在省市不许为空!", "软件提示");
                cbxProvinceCode.Focus();
                return;
            }
            if (String.IsNullOrEmpty(txtAddress.Text.Trim()))
            {
                MessageBox.Show("地址不许为空!", "软件提示");
                txtAddress.Focus();
                return;
            }

            if (this.Tag.ToString() == "Add")
            {
                DataGridViewRow dgvr = ar.AddDataGridViewRow(formAgentRecord.dgvAgentRecord, formAgentRecord.bsAgentRecord);
                dgvr.Cells["CustomerName"].Value      = txtCustomerName.Text.Trim();
                dgvr.Cells["JuridicalPerson"].Value   = txtJuridicalPerson.Text.Trim();
                dgvr.Cells["PhoneNumber"].Value       = txtPhoneNumber.Text.Trim();
                dgvr.Cells["ProvinceCode"].Value      = cbxProvinceCode.SelectedValue;
                dgvr.Cells["Address"].Value           = txtAddress.Text.Trim();
                dgvr.Cells["PostalCode"].Value        = txtPostalCode.Text.Trim();
                dgvr.Cells["URL"].Value               = txtURL.Text.Trim();
                dgvr.Cells["OpenAccBankName"].Value   = txtOpenAccBankName.Text.Trim();
                dgvr.Cells["AccountNumber"].Value     = txtAccountNumber.Text.Trim();
                dgvr.Cells["CertificateNumber"].Value = txtCertificateNumber.Text.Trim();
                dgvr.Cells["IsCancel"].Value          = useful.GetFlagValue(cbIsCancel);
                dgvr.Cells["CustomerType"].Value      = "1";//代理商类型为1,默认值,不许修改的
                dgvr.Cells["Remark"].Value            = txtRemark.Text.Trim();
                dgvr.Cells["OperatorCode"].Value      = GlobalProperty.OperatorCode;
                if (ar.Insert(formAgentRecord.dgvAgentRecord, formAgentRecord.bsAgentRecord))
                {
                    formAgentRecord.bsAgentRecord.DataSource  = ar.GetDataTable("Customer", " Where CustomerType = '1'");
                    formAgentRecord.dgvAgentRecord.DataSource = formAgentRecord.bsAgentRecord;
                    //formAgentRecord.bsAgentRecord.CancelEdit();//取消当前的编辑操作。
                    if (MessageBox.Show("保存成功,是否继续添加?", "软件提示", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation) == DialogResult.Yes)
                    {
                        txtCustomerName.Text          = "";
                        txtJuridicalPerson.Text       = "";
                        txtPhoneNumber.Text           = "";
                        cbxProvinceCode.SelectedIndex = -1;
                        txtAddress.Text           = "";
                        txtPostalCode.Text        = "";
                        txtURL.Text               = "";
                        txtOpenAccBankName.Text   = "";
                        txtAccountNumber.Text     = "";
                        txtCertificateNumber.Text = "";
                        cbIsCancel.Checked        = false; //表示不取消代理
                        txtRemark.Text            = "";
                        txtCustomerName.Focus();
                    }
                    else
                    {
                        this.Close();
                    }
                }
                else
                {
                    MessageBox.Show("保存失败!", "软件提示");
                }
            }
            if (this.Tag.ToString() == "Edit")
            {
                DataGridViewRow dgvr = formAgentRecord.dgvAgentRecord.CurrentRow;
                dgvr.Cells["CustomerName"].Value      = txtCustomerName.Text.Trim();
                dgvr.Cells["JuridicalPerson"].Value   = txtJuridicalPerson.Text.Trim();
                dgvr.Cells["PhoneNumber"].Value       = txtPhoneNumber.Text.Trim();
                dgvr.Cells["ProvinceCode"].Value      = cbxProvinceCode.SelectedValue;
                dgvr.Cells["Address"].Value           = txtAddress.Text.Trim();
                dgvr.Cells["PostalCode"].Value        = txtPostalCode.Text.Trim();
                dgvr.Cells["URL"].Value               = txtURL.Text.Trim();
                dgvr.Cells["OpenAccBankName"].Value   = txtOpenAccBankName.Text.Trim();
                dgvr.Cells["AccountNumber"].Value     = txtAccountNumber.Text.Trim();
                dgvr.Cells["CertificateNumber"].Value = txtCertificateNumber.Text.Trim();
                dgvr.Cells["IsCancel"].Value          = useful.GetFlagValue(cbIsCancel);
                //dgvr.Cells["CustomerType"].Value = "1";//代理商类型为1,默认值,不许修改
                dgvr.Cells["Remark"].Value = txtRemark.Text.Trim();
                //dgvr.Cells["OperatorCode"].Value = GlobalProperty.OperatorCode;
                if (ar.Update(formAgentRecord.bsAgentRecord))
                {
                    MessageBox.Show("保存成功!", "软件提示");
                    this.Close();
                }
                else
                {
                    MessageBox.Show("保存失败!", "软件提示");
                }
            }
        }