private void dgvRetailCustomer_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            RetailSaleOrderBill rsb = new RetailSaleOrderBill();

            formRetailOperation.CustomerNo                    = Convert.ToInt32(dgvRetailCustomer.CurrentRow.Cells["CustomerId"].Value);
            formRetailOperation.txtCustomerName.Text          = dgvRetailCustomer.CurrentRow.Cells["CustomerName"].Value.ToString();
            formRetailOperation.cbxProvinceCode.SelectedValue = dgvRetailCustomer.CurrentRow.Cells["ProvinceCode"].Value;
            formRetailOperation.txtAddress.Text               = dgvRetailCustomer.CurrentRow.Cells["Address"].Value.ToString();
            formRetailOperation.txtPostalCode.Text            = dgvRetailCustomer.CurrentRow.Cells["PostalCode"].Value.ToString();
            formRetailOperation.txtPhoneNumber.Text           = dgvRetailCustomer.CurrentRow.Cells["PhoneNumber"].Value.ToString();
            formRetailOperation.txtURL.Text                   = dgvRetailCustomer.CurrentRow.Cells["URL"].Value.ToString();
            if (dgvRetailCustomer.CurrentRow.Cells["CustomerType"].Value.ToString() == "2")  //个人
            {
                formRetailOperation.rbCustomerType2.Checked = true;
            }
            else  //单位
            {
                formRetailOperation.rbCustomerType3.Checked = true;
            }
            formRetailOperation.txtRemark.Text = dgvRetailCustomer.CurrentRow.Cells["Remark"].Value.ToString();
            //显示销售单记录
            formRetailOperation.bsSaleOrderBill.DataSource  = rsb.GetDataTable("SaleBill", "Where CustomerId = '" + dgvRetailCustomer.CurrentRow.Cells["CustomerId"].Value.ToString() + "'");
            formRetailOperation.dgvSaleOrderBill.DataSource = formRetailOperation.bsSaleOrderBill;
            //
            formRetailOperation.toolSave.Enabled   = false;
            formRetailOperation.toolCancel.Enabled = false;
            //
            formRetailOperation.toolAdd.Enabled    = true;
            formRetailOperation.toolAmend.Enabled  = true;
            formRetailOperation.toolDelete.Enabled = true;
            formRetailOperation.toolBrowse.Enabled = true;
            //
            this.Close();
        }
        private void SetOrderBillInfo(string strSaleBillNo)
        {
            string              strSql = null;
            DataTable           dt     = null;
            RetailSaleOrderBill rsob   = new RetailSaleOrderBill();

            strSql = "Select SaleOrderBill.*,Customer.* From SaleOrderBill,Customer Where SaleOrderBill.CustomerId = Customer.CustomerId and SaleBillNo = '" + strSaleBillNo + "'";
            dt     = rsob.GetDataTable(strSql);
            if (dt.Rows.Count == 0)
            {
                MessageBox.Show("该销售单号不存在!", "软件提示");
                txtSaleBillNo.Focus();
                return;
            }
            //零售用户的基本档案信息
            txtCustomerName.Text = dt.Rows[0]["CustomerName"].ToString();
            txtPhoneNumber.Text  = dt.Rows[0]["PhoneNumber"].ToString();
            txtPostalCode.Text   = dt.Rows[0]["PostalCode"].ToString();
            txtAddress.Text      = dt.Rows[0]["Address"].ToString();
            //销售订单表的信息
            dtpBillDate.Value = Convert.ToDateTime(dt.Rows[0]["BillDate"]);
            cbxGoodsTypeCode.SelectedValue   = dt.Rows[0]["GoodsTypeCode"];
            cbxGoodsSeriesCode.SelectedValue = dt.Rows[0]["GoodsSeriesCode"];
            txtUnitPrice.Text = dt.Rows[0]["UnitPrice"].ToString();
            txtDiscount.Text  = dt.Rows[0]["Discount"].ToString();
            txtQuantity.Text  = dt.Rows[0]["Quantity"].ToString();
            txtSaleMoney.Text = GetSaleMoneyString();
            if (dt.Rows[0]["IsNeedInvoice"].ToString() == "1")  //需要发票
            {
                rbIsNeedInvoice1.Checked = true;
                if (dt.Rows[0]["WriteOffType"].ToString() == "1")  //个人
                {
                    chbWriteOffType1.Checked   = true;
                    txtWriteOffName1.Text      = dt.Rows[0]["WriteOffName"].ToString();
                    txtCertificateNumber1.Text = dt.Rows[0]["CertificateNumber"].ToString();
                }
                else  //单位
                {
                    chbWriteOffType2.Checked   = true;
                    txtWriteOffName2.Text      = dt.Rows[0]["WriteOffName"].ToString();
                    txtCertificateNumber2.Text = dt.Rows[0]["CertificateNumber"].ToString();
                }
            }
            else  //不需要发票
            {
                rbIsNeedInvoice0.Checked = true;
            }
            cbxEmployeeCode.SelectedValue = dt.Rows[0]["EmployeeCode"];
            if (dt.Rows[0]["SignDate"] == DBNull.Value)
            {
                dtpSignDate.Checked = false;
            }
            else
            {
                dtpSignDate.Value = Convert.ToDateTime(dt.Rows[0]["SignDate"]);
            }
            txtRemark.Text = dt.Rows[0]["Remark"].ToString();
        }
Example #3
0
        private void GetBarterBaseBillInfo(string strBarterBillNo)
        {
            string              strSql = null;
            DataTable           dt     = null;
            RetailSaleOrderBill rsob   = new RetailSaleOrderBill();

            strSql = "Select BarterBaseBill.*,Customer.* From BarterBaseBill,Customer Where BarterBaseBill.CustomerId = Customer.CustomerId and BarterBillNo = '" + strBarterBillNo + "'";
            dt     = rbbb.GetDataTable(strSql);
            if (dt.Rows.Count > 0)
            {
                txtBarterBillNo.Text             = dt.Rows[0]["BarterBillNo"].ToString();
                txtSaleBillNo.Text               = dt.Rows[0]["SaleBillNo"].ToString();
                txtCustomerName.Text             = dt.Rows[0]["CustomerName"].ToString();
                this.intCustomerId               = Convert.ToInt32(dt.Rows[0]["CustomerId"]);
                cbxBarterType.SelectedValue      = dt.Rows[0]["BarterType"];
                dtpBarterBillDate.Value          = Convert.ToDateTime(dt.Rows[0]["BarterBillDate"]);
                cbxGoodsTypeCode.SelectedValue   = dt.Rows[0]["GoodsTypeCode"];
                cbxGoodsSeriesCode.SelectedValue = dt.Rows[0]["GoodsSeriesCode"];
                txtUnitPrice.Text = dt.Rows[0]["UnitPrice"].ToString();
                cbxGoodsTypeCode1.SelectedValue   = dt.Rows[0]["GoodsTypeCode1"];
                cbxGoodsSeriesCode1.SelectedValue = dt.Rows[0]["GoodsSeriesCode1"];
                txtUnitPrice1.Text     = dt.Rows[0]["UnitPrice1"].ToString();
                txtBarterQuantity.Text = dt.Rows[0]["BarterQuantity"].ToString();
                txtPhoneNumber.Text    = dt.Rows[0]["PhoneNumber"].ToString();
                if (dt.Rows[0]["IsNeedInvoice"].ToString() == "0")
                {
                    rbIsNeedInvoice0.Checked = true;
                }
                else
                {
                    rbIsNeedInvoice1.Checked = true;
                }
                txtAddress.Text = dt.Rows[0]["Address"].ToString();
                txtRemark1.Text = dt.Rows[0]["Remark1"].ToString();
                cbxEmployeeCode1.SelectedValue = dt.Rows[0]["EmployeeCode1"];
                if (Convert.IsDBNull(dt.Rows[0]["SignDate1"]))
                {
                    dtpSignDate1.Checked = false;
                }
                else
                {
                    dtpSignDate1.Value = Convert.ToDateTime(dt.Rows[0]["SignDate1"]);
                }
            }
        }
Example #4
0
        private void RetrieveSaleBillInfo(string strSaleBillNo)
        {
            string              strSql = null;
            DataTable           dt     = null;
            RetailSaleOrderBill rsob   = new RetailSaleOrderBill();

            strSql = "Select SaleOrderBill.*,Customer.* From SaleOrderBill,Customer Where SaleOrderBill.CustomerId = Customer.CustomerId and SaleBillNo = '" + strSaleBillNo + "'";
            dt     = rsob.GetDataTable(strSql);
            if (dt.Rows.Count > 0)
            {
                SetSaleBillInfo(dt.Rows[0]);
            }
            else
            {
                MessageBox.Show("该销售单号不存在!", "软件提示");
                txtSaleBillNo.Focus();
                return;
            }
        }
        private void btnSave_Click(object sender, EventArgs e)
        {
            RetailSaleOrderBill rsb = new RetailSaleOrderBill();

            if (cbxGoodsTypeCode.SelectedValue == null)
            {
                MessageBox.Show("订购种类不许为空!", "软件提示");
                cbxGoodsTypeCode.Focus();
                return;
            }
            if (cbxGoodsSeriesCode.SelectedValue == null)
            {
                MessageBox.Show("订购版本不许为空!", "软件提示");
                cbxGoodsSeriesCode.Focus();
                return;
            }
            if (String.IsNullOrEmpty(txtDiscount.Text.Trim()))
            {
                MessageBox.Show("折扣不许为空!", "软件提示");
                txtDiscount.Focus();
                return;
            }
            if (String.IsNullOrEmpty(txtQuantity.Text.Trim()))
            {
                MessageBox.Show("数量不许为空!", "软件提示");
                txtQuantity.Focus();
                return;
            }
            else
            {
                if (Convert.ToInt32(txtQuantity.Text.Trim()) == 0)
                {
                    MessageBox.Show("数量不许为零!", "软件提示");
                    txtQuantity.Focus();
                    return;
                }
            }
            //选择是
            if (rbIsNeedInvoice1.Checked)
            {
                //选择个人1
                if (chbWriteOffType1.Checked)
                {
                    if (String.IsNullOrEmpty(txtWriteOffName1.Text.Trim()))
                    {
                        MessageBox.Show("姓名不许为空!", "软件提示");
                        txtWriteOffName1.Focus();
                        return;
                    }
                    if (String.IsNullOrEmpty(txtCertificateNumber1.Text.Trim()))
                    {
                        MessageBox.Show("身份证号不许为空!", "软件提示");
                        txtCertificateNumber1.Focus();
                        return;
                    }
                }
                //选择单位2
                if (chbWriteOffType2.Checked)
                {
                    if (String.IsNullOrEmpty(txtWriteOffName2.Text.Trim()))
                    {
                        MessageBox.Show("单位名称不许为空!", "软件提示");
                        txtWriteOffName2.Focus();
                        return;
                    }
                    if (String.IsNullOrEmpty(txtCertificateNumber2.Text.Trim()))
                    {
                        MessageBox.Show("税号不许为空!", "软件提示");
                        txtCertificateNumber2.Focus();
                        return;
                    }
                }
            }
            if (cbxPayTypeCode.SelectedValue == null)
            {
                MessageBox.Show("交易方式不许为空!", "软件提示");
                cbxPayTypeCode.Focus();
                return;
            }
            if (cbxBankCode.SelectedValue == null)
            {
                MessageBox.Show("预存银行不许为空!", "软件提示");
                cbxBankCode.Focus();
                return;
            }
            if (String.IsNullOrEmpty(txtReceiptMoney.Text.Trim()))
            {
                MessageBox.Show("实收金额不许为空!", "软件提示");
                txtReceiptMoney.Focus();
                return;
            }
            else
            {
                //若实收金额小于销售总额,则程序给与提示
                if (Convert.ToDecimal(txtReceiptMoney.Text.Trim()) < Convert.ToDecimal(txtSaleMoney.Text.Trim()))
                {
                    MessageBox.Show("实收金额不许小于销售总额!", "软件提示");
                    txtReceiptMoney.Focus();
                    return;
                }
            }
            if (cbxGoodsTypeCode1.SelectedValue == null)
            {
                MessageBox.Show("实发种类不许为空!", "软件提示");
                cbxGoodsTypeCode1.Focus();
                return;
            }
            if (cbxGoodsSeriesCode1.SelectedValue == null)
            {
                MessageBox.Show("实发版本不许为空!", "软件提示");
                cbxGoodsSeriesCode1.Focus();
                return;
            }
            if (String.IsNullOrEmpty(txtExpressBillNo.Text.Trim()))
            {
                MessageBox.Show("快递单号不许为空!", "软件提示");
                txtExpressBillNo.Focus();
                return;
            }
            if (cbxConsignCorpCode.SelectedValue == null)
            {
                MessageBox.Show("发货公司不许为空!", "软件提示");
                cbxConsignCorpCode.Focus();
                return;
            }
            if (Convert.ToInt32(txtDiscount.Text.Trim()) == 0)
            {
                if (MessageBox.Show("折扣为零,是否继续?", "软件提示", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button2) == DialogResult.No)
                {
                    txtDiscount.Focus();
                    return;
                }
            }

            if (cbxGoodsTypeCode1.SelectedValue != cbxGoodsTypeCode.SelectedValue)
            {
                if (MessageBox.Show("实发种类不等于订购种类,是否继续?", "软件提示", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button2) == DialogResult.No)
                {
                    cbxGoodsTypeCode1.Focus();
                    return;
                }
            }
            if (cbxGoodsSeriesCode1.SelectedValue != cbxGoodsSeriesCode.SelectedValue)
            {
                if (MessageBox.Show("实发版本不等于订购版本,是否继续?", "软件提示", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button2) == DialogResult.No)
                {
                    cbxGoodsSeriesCode1.Focus();
                    return;
                }
            }
            if (this.Tag.ToString() == "Add")
            {
                DataGridViewRow dgvr = rsb.AddDataGridViewRow(formRetailOperation.dgvSaleOrderBill, formRetailOperation.bsSaleOrderBill);
                dgvr.Cells["SaleBillNo"].Value      = txtSaleBillNo.Text.Trim();
                dgvr.Cells["BillDate"].Value        = dtpBillDate.Value;
                dgvr.Cells["CustomerId"].Value      = formRetailOperation.CustomerNo;
                dgvr.Cells["GoodsTypeCode"].Value   = cbxGoodsTypeCode.SelectedValue;
                dgvr.Cells["GoodsSeriesCode"].Value = cbxGoodsSeriesCode.SelectedValue;
                dgvr.Cells["UnitPrice"].Value       = Convert.ToDecimal(txtUnitPrice.Text);
                dgvr.Cells["Discount"].Value        = Convert.ToDecimal(txtDiscount.Text);
                dgvr.Cells["Quantity"].Value        = Convert.ToInt32(txtQuantity.Text);
                if (rbIsNeedInvoice0.Checked)
                {
                    dgvr.Cells["IsNeedInvoice"].Value = "0";  //不要发票
                }
                if (rbIsNeedInvoice1.Checked)
                {
                    dgvr.Cells["IsNeedInvoice"].Value = "1";   //要发票
                }
                if (chbWriteOffType1.Checked)
                {
                    dgvr.Cells["WriteOffType"].Value      = "1"; //个人索要发票
                    dgvr.Cells["WriteOffName"].Value      = txtWriteOffName1.Text.Trim();
                    dgvr.Cells["CertificateNumber"].Value = txtCertificateNumber1.Text.Trim();
                }
                if (chbWriteOffType2.Checked)
                {
                    dgvr.Cells["WriteOffType"].Value      = "2"; //单位索要发票
                    dgvr.Cells["WriteOffName"].Value      = txtWriteOffName2.Text.Trim();
                    dgvr.Cells["CertificateNumber"].Value = txtCertificateNumber2.Text.Trim();
                }

                dgvr.Cells["PayTypeCode"].Value = cbxPayTypeCode.SelectedValue;
                dgvr.Cells["BankCode"].Value    = cbxBankCode.SelectedValue;
                //dgvr.Cells["SaleDate"].Value =
                //dgvr.Cells["SaleBillNo"].Value =
                //dgvr.Cells["SaleBillNo"].Value =
                //dgvr.Cells["SaleBillNo"].Value =
                //dgvr.Cells["SaleBillNo"].Value =
                //dgvr.Cells["SaleBillNo"].Value =
                //dgvr.Cells["SaleBillNo"].Value =
                //dgvr.Cells["SaleBillNo"].Value =
                //dgvr.Cells["SaleBillNo"].Value =
                //dgvr.Cells["SaleBillNo"].Value =
                //dgvr.Cells["SaleBillNo"].Value =
                //dgvr.Cells["SaleBillNo"].Value =
                //dgvr.Cells["SaleBillNo"].Value =
                //dgvr.Cells["SaleBillNo"].Value =
                //dgvr.Cells["SaleBillNo"].Value =
                //dgvr.Cells["SaleBillNo"].Value =



                //if (dgvr.Insert(formRetailOperation.bsSaleBill))
                //{
                //    if (MessageBox.Show("保存成功,是否继续添加?", "软件提示", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation) == DialogResult.Yes)
                //    {

                //    }
                //    else
                //    {
                //        this.Close();
                //    }
                //}
                //else
                //{
                //    MessageBox.Show("保存失败!", "软件提示");
                //}
            }
        }