Exemplo n.º 1
0
        private void GetBarterExchangeInfo(string strBarterBillNo)
        {
            string    strSql = null;
            DataTable dt     = null;

            strSql = "Select BarterExchangeBill.* From BarterExchangeBill Where BarterBillNo = '" + strBarterBillNo + "'";
            dt     = rbeb.GetDataTable(strSql);
            if (dt.Rows.Count > 0)
            {
                if (this.Tag.ToString() == "Add")  //每个换货单[号]只允许存在一个调款单[号]
                {
                    useful.SetControlsState(groupBox3, false);
                    btnSave.Enabled = false;
                }
                cbxPayTypeCode.SelectedValue   = dt.Rows[0]["PayTypeCode"];
                txtTradeMoney.Text             = dt.Rows[0]["TradeMoney"].ToString();
                cbxBankCode.SelectedValue      = dt.Rows[0]["BankCode"];
                txtTradeBillNo.Text            = dt.Rows[0]["TradeBillNo"].ToString();
                dtpTradeDate.Value             = Convert.ToDateTime(dt.Rows[0]["TradeDate"]); //交易日期不许为空!
                cbxEmployeeCode2.SelectedValue = dt.Rows[0]["EmployeeCode2"];
                if (dt.Rows[0]["SignDate2"] == DBNull.Value)                                  //签字日期可以为空
                {
                    dtpSignDate2.Checked = false;
                }
                else
                {
                    dtpSignDate2.Value = Convert.ToDateTime(dt.Rows[0]["SignDate2"]);
                }
            }
            else
            {
                useful.SetControlsState(groupBox3, true);
                btnSave.Enabled = true;
            }
        }
        private void btnQuery_Click(object sender, EventArgs e)
        {
            string strSql = String.Empty;  //声明string变量并初始化
            RetailBarterExchangeBill rbeb = new RetailBarterExchangeBill();

            if (!chbIsCDNo.Checked)                                         //没有选中光盘号查询
            {
                strSql = rbeb.BarterExchangeBillSql + GetQueryInfoString(); //设置基本的Sql语句
            }
            if (chbIsCDNo.Checked)                                          //选中光盘号查询
            {
                if (String.IsNullOrEmpty(txtCDNo.Text.Trim()))
                {
                    MessageBox.Show("请输入光盘号!", "软件提示");
                    txtCDNo.Focus();
                    return;
                }
            }
            formRetailBarterExchangeBill.dgvBarterExchangeBill.DataSource = rbeb.GetDataTable(strSql);
            this.Close();
        }