//-------交易

        //-------发货
        public void RetrieveConsignBillInfo(string strSaleBillNo)
        {
            string                strSql = null;
            DataTable             dt     = null;
            RetailSaleConsignBill rscb   = new RetailSaleConsignBill();

            strSql = "Select * From  SaleConsignBill Where SaleBillNo = '" + strSaleBillNo + "'";
            dt     = rscb.GetDataTable(strSql);
            if (dt.Rows.Count > 0)
            {
                useful.SetControlsState(gbConsign, false);
                SetConsignBillInfo(dt.Rows[0]);
                //赋值
            }
            else
            {
                useful.SetControlsState(gbConsign, true);
            }
        }
Exemple #2
0
        private void btnQuery_Click(object sender, EventArgs e)
        {
            RetailSaleConsignBill rscb = new RetailSaleConsignBill();
            string strSql = null;

            if (!chbIsCDNo.Checked) //没有选中光盘号查询
            {
                strSql = "Select SaleConsignBill.* From SaleConsignBill,Customer,SaleOrderBill "
                         + "Where SaleConsignBill.SaleBillNo = SaleOrderBill.SaleBillNo and SaleOrderBill.CustomerId = Customer.CustomerId ";
                if (!String.IsNullOrEmpty(txtCustomerName.Text.Trim()))
                {
                    strSql += " and CustomerName like '%" + txtCustomerName.Text.Trim() + "%'";
                }
                if (!(cbxProvinceCode.SelectedValue == null))
                {
                    strSql += " and ProvinceCode = '" + cbxProvinceCode.SelectedValue.ToString() + "'";
                }
                if (!String.IsNullOrEmpty(txtAddress.Text.Trim()))
                {
                    strSql += " and Address like '%" + txtAddress.Text.Trim() + "%'";
                }
                if (!String.IsNullOrEmpty(txtPhoneNumber.Text.Trim()))
                {
                    strSql += " and PhoneNumber like '%" + txtPhoneNumber.Text.Trim() + "%'";
                }
                if (!String.IsNullOrEmpty(txtSaleBillNo.Text.Trim()))
                {
                    strSql += " and SaleOrderBill.SaleBillNo like '%" + txtSaleBillNo.Text.Trim() + "%'";
                }
                if (!(cbxConsignCorpCode.SelectedValue == null))
                {
                    strSql += " and SaleConsignBill.ConsignCorpCode = '" + cbxConsignCorpCode.SelectedValue.ToString() + "'";
                }
                if (dtpConsignDate.Checked)
                {
                    strSql += " and SaleConsignBill.ConsignDate = '" + dtpConsignDate.Value.Date + "'";
                }
                if (!String.IsNullOrEmpty(txtExpressBillNo.Text.Trim()))
                {
                    strSql += " and SaleConsignBill.ExpressBillNo like '%" + txtExpressBillNo.Text.Trim() + "'";
                }
                if (!(cbxEmployeeCode4.SelectedValue == null))
                {
                    strSql += " and SaleConsignBill.EmployeeCode4 = '" + cbxEmployeeCode4.SelectedValue.ToString() + "'";
                }
            }
            if (chbIsCDNo.Checked) //选中光盘号查询
            {
                if (String.IsNullOrEmpty(txtCDNo.Text.Trim()))
                {
                    MessageBox.Show("请输入光盘号!", "软件提示");
                    txtCDNo.Focus();
                    return;
                }
                strSql = "Select SaleConsignBill.* From SaleConsignBill,Customer,SaleOrderBill,SaleCDRecord "
                         + "Where SaleCDRecord.SaleConsignBillId = SaleConsignBill.Id and  SaleConsignBill.SaleBillNo = SaleOrderBill.SaleBillNo and SaleOrderBill.CustomerId = Customer.CustomerId and SaleCDRecord.CDNo = '" + txtCDNo.Text.Trim() + "'";
            }
            formRetailSaleConsignBill.bsSaleConsignBill.DataSource  = rscb.GetDataTable(strSql);
            formRetailSaleConsignBill.dgvSaleConsignBill.DataSource = formRetailSaleConsignBill.bsSaleConsignBill;
            this.Close();
        }
        private void btnSave_Click(object sender, EventArgs e)
        {
            RetailSaleConsignBill rscb = new RetailSaleConsignBill();

            if (String.IsNullOrEmpty(txtCustomerName.Text.Trim()))
            {
                MessageBox.Show("销售订单信息不许为空!", "软件提示");
                txtSaleBillNo.Focus();
                return;
            }
            if (cbxPayTypeCode.SelectedValue == null)
            {
                MessageBox.Show("交易信息不许为空!", "软件提示");
                cbxPayTypeCode.Focus();
                return;
            }
            if (cbxGoodsTypeCode1.SelectedValue == null)
            {
                MessageBox.Show("实发种类不许为空!", "软件提示");
                cbxGoodsTypeCode1.Focus();
                return;
            }
            else
            {
                if (cbxGoodsTypeCode1.SelectedValue.ToString() != cbxGoodsTypeCode.SelectedValue.ToString())
                {
                    if (MessageBox.Show("实发种类不等于订购种类,是否继续", "软件提示", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation) == DialogResult.No)
                    {
                        cbxGoodsTypeCode1.Focus();
                        return;
                    }
                }
            }
            if (cbxGoodsSeriesCode1.SelectedValue == null)
            {
                MessageBox.Show("实发版本不许为空!", "软件提示");
                cbxGoodsSeriesCode1.Focus();
                return;
            }
            else
            {
                if (cbxGoodsSeriesCode1.SelectedValue.ToString() != cbxGoodsSeriesCode.SelectedValue.ToString())
                {
                    if (MessageBox.Show("实发版本不等于订购版本,是否继续", "软件提示", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation) == DialogResult.No)
                    {
                        cbxGoodsSeriesCode1.Focus();
                        return;
                    }
                }
            }
            if (String.IsNullOrEmpty(txtExpressBillNo.Text.Trim()))
            {
                MessageBox.Show("快递单号不许为空!", "软件提示");
                txtExpressBillNo.Focus();
                return;
            }
            if (cbxConsignCorpCode.SelectedValue == null)
            {
                MessageBox.Show("发货公司不许为空!", "软件提示");
                cbxConsignCorpCode.Focus();
                return;
            }
            if (cbxEmployeeCode4.SelectedValue == null)
            {
                MessageBox.Show("发货人不许为空!", "软件提示");
                cbxEmployeeCode4.Focus();
                return;
            }
            if (this.Tag.ToString() == "Add")
            {
                DataGridViewRow dgvr = rscb.AddDataGridViewRow(formRetailSaleConsignBill.dgvSaleConsignBill, formRetailSaleConsignBill.bsSaleConsignBill);
                dgvr.Cells["SaleBillNo"].Value = txtSaleBillNo.Text.Trim();
                if (rbIsComplete0.Checked)
                {
                    dgvr.Cells["IsComplete"].Value = "0";
                }
                else
                {
                    dgvr.Cells["IsComplete"].Value = "1";
                }
                dgvr.Cells["GoodsTypeCode1"].Value   = cbxGoodsTypeCode1.SelectedValue;
                dgvr.Cells["GoodsSeriesCode1"].Value = cbxGoodsSeriesCode1.SelectedValue;
                dgvr.Cells["ConsignDate"].Value      = dtpConsignDate.Value.Date;
                dgvr.Cells["ExpressBillNo"].Value    = txtExpressBillNo.Text.Trim();
                dgvr.Cells["ConsignCorpCode"].Value  = cbxConsignCorpCode.SelectedValue;
                dgvr.Cells["EmployeeCode4"].Value    = cbxEmployeeCode4.SelectedValue;
                if (dtpSignDate4.Checked)
                {
                    dgvr.Cells["SignDate4"].Value = DBNull.Value;
                }
                else
                {
                    dgvr.Cells["SignDate4"].Value = dtpSignDate4.Value.Date;
                }
                dgvr.Cells["Remark2"].Value      = txtRemark2.Text.Trim();
                dgvr.Cells["OperatorCode"].Value = GlobalProperty.OperatorCode;
                dgvr.Cells["AppendDate"].Value   = GlobalProperty.DBTime.Date;
                if (rscb.Insert(formRetailSaleConsignBill.bsSaleConsignBill))
                {
                    if (MessageBox.Show("保存成功,是否录入光盘号?", "软件提示", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation) == DialogResult.Yes)
                    {
                        m_SaleConsignBillId = rscb.GetMaxIdOfCurrentOperator(GlobalProperty.OperatorCode);
                        btnCD_Click(sender, e);
                    }
                    formRetailSaleConsignBill.bsSaleConsignBill.DataSource  = rscb.GetDataTable("SaleConsignBill", "Where OperatorCode = '" + GlobalProperty.OperatorCode + "' and AppendDate = '" + GlobalProperty.DBTime.Date + "'");
                    formRetailSaleConsignBill.dgvSaleConsignBill.DataSource = formRetailSaleConsignBill.bsSaleConsignBill;
                    useful.InitFormContros(gbOrder, null);
                    useful.InitFormContros(gbConsign, null);
                    useful.InitFormContros(gbTrade, null);
                    txtSaleBillNo.Text = "";
                    txtSaleBillNo.Focus();
                }
                else
                {
                    MessageBox.Show("保存失败!", "软件提示");
                }
            }
            if (this.Tag.ToString() == "Edit")
            {
                DataGridViewRow dgvr = formRetailSaleConsignBill.dgvSaleConsignBill.CurrentRow;
                if (rbIsComplete0.Checked)
                {
                    dgvr.Cells["IsComplete"].Value = "0";
                }
                else
                {
                    dgvr.Cells["IsComplete"].Value = "1";
                }
                dgvr.Cells["GoodsTypeCode1"].Value   = cbxGoodsTypeCode1.SelectedValue;
                dgvr.Cells["GoodsSeriesCode1"].Value = cbxGoodsSeriesCode1.SelectedValue;
                dgvr.Cells["ConsignDate"].Value      = dtpConsignDate.Value.Date;
                dgvr.Cells["ExpressBillNo"].Value    = txtExpressBillNo.Text.Trim();
                dgvr.Cells["ConsignCorpCode"].Value  = cbxConsignCorpCode.SelectedValue;
                dgvr.Cells["EmployeeCode4"].Value    = cbxEmployeeCode4.SelectedValue;
                if (dtpSignDate4.Checked)
                {
                    dgvr.Cells["SignDate4"].Value = DBNull.Value;
                }
                else
                {
                    dgvr.Cells["SignDate4"].Value = dtpSignDate4.Value.Date;
                }
                dgvr.Cells["Remark2"].Value = txtRemark2.Text.Trim();
                if (rscb.Update(formRetailSaleConsignBill.bsSaleConsignBill))
                {
                    MessageBox.Show("保存成功!", "软件提示");
                    this.Close();
                }
                else
                {
                    MessageBox.Show("保存失败!", "软件提示");
                }
            }
        }