Beispiel #1
0
 private void btnClose_Click(object sender, EventArgs e)
 {
     try
     {
         string sqlStr;
         sqlStr = "update tbl_OrderForm set orderStatus = '已出库' where orderStatus = '未出库' ";
         CDataBase.UpdateDB(sqlStr);
         if ((ob_FrmInfoCustomer != null && !ob_FrmInfoCustomer.IsDisposed) ||
             (ob_FrmBookCity != null && !ob_FrmBookCity.IsDisposed) ||
             (ob_FrmOrder != null && !ob_FrmOrder.IsDisposed) ||
             (ob_FrmHelp != null && !ob_FrmHelp.IsDisposed))
         {
             if (MessageBox.Show("已打开了部分子系统,确实要退出系统吗?", "询问",
                                 MessageBoxButtons.YesNo, MessageBoxIcon.Question,
                                 MessageBoxDefaultButton.Button2) == DialogResult.Yes)
             {
                 Application.Exit();
             }
         }
         else
         {
             Application.Exit();
         }
     }
     catch (Exception ex)
     {
         CDataBase.conn.Close();
         MessageBox.Show(ex.Message);
     }
 }
        private void btnClose_Click(object sender, EventArgs e)
        {
            string sqlStr;

            sqlStr = "update tbl_OrderForm set orderStatus = '已送达' where orderStatus = '已出库' ";
            CDataBase.UpdateDB(sqlStr);
            if ((ob_FrmBook != null && !ob_FrmBook.IsDisposed) ||
                (ob_FrmFinance != null && !ob_FrmFinance.IsDisposed) ||
                (ob_FrmStock != null && !ob_FrmStock.IsDisposed) ||
                (ob_FrmInfoAdmin != null && !ob_FrmInfoAdmin.IsDisposed) ||
                (ob_FrmUser != null && !ob_FrmUser.IsDisposed) ||
                (ob_FrmDataBase != null && !ob_FrmDataBase.IsDisposed) ||
                (ob_FrmHelp != null && !ob_FrmHelp.IsDisposed))
            {
                if (MessageBox.Show("已打开了部分子系统,确实要退出系统吗?", "询问",
                                    MessageBoxButtons.YesNo, MessageBoxIcon.Question,
                                    MessageBoxDefaultButton.Button2) == DialogResult.Yes)
                {
                    Application.Exit();
                }
            }
            else
            {
                Application.Exit();
            }
        }
Beispiel #3
0
 private void btnDelete_Click(object sender, EventArgs e)
 {
     try
     {
         string userName;
         if (dgrdvUser.DataSource == null)
         {
             MessageBox.Show("没有可以删除的用户", "提示");
         }
         else
         {
             int n = this.dgrdvUser.CurrentCell.RowIndex;
             userName = this.dgrdvUser.Rows[n].Cells[0].Value.ToString().Trim();
             if (MessageBox.Show("确定要删除用户“" + userName + "”吗?", "删除用户",
                                 MessageBoxButtons.YesNo, MessageBoxIcon.Question,
                                 MessageBoxDefaultButton.Button2) == DialogResult.Yes)
             {
                 string sqlStr = "delete from tbl_User where userName='******'";
                 CDataBase.UpdateDB(sqlStr);
                 dgrdvUser.Rows.RemoveAt(n);
             }
         }
     }
     catch (Exception ex)
     {
         CDataBase.conn.Close();
         MessageBox.Show(ex.Message);
     }
 }
Beispiel #4
0
 private void btnDeletePswPctQuestion_Click(object sender, EventArgs e)
 {
     try
     {
         if (MessageBox.Show("删除密保问题答案后,一旦忘记用户密码,将无法找回,确定要删除吗?",
                             "删除密保问题答案", MessageBoxButtons.YesNo, MessageBoxIcon.Warning,
                             MessageBoxDefaultButton.Button2) == DialogResult.Yes)
         {
             string sqlStr = "delete from tbl_Information where userName='******'";
             if (CDataBase.UpdateDB(sqlStr))
             {
                 txtName.Text    = "";
                 txtAnswer1.Text = "";
                 txtAnswer2.Text = "";
                 txtAnswer3.Text = "";
                 sqlStr          = "update tbl_User set firstLogin='******' where userName='******'";
                 CDataBase.UpdateDB(sqlStr);
                 MessageBox.Show("删除密保问题成功", "恭喜");
                 set = true;
                 txtName.Focus();
             }
         }
     }
     catch (Exception ex)
     {
         CDataBase.conn.Close();
         MessageBox.Show(ex.Message);
     }
 }
Beispiel #5
0
 private void btnAdd_Click(object sender, EventArgs e)
 {
     try
     {
         if (btnAdd.Text == "添加")
         {
             btnAdd.Text       = "确定";
             btnDelete.Enabled = false;
             ObjOpen();
         }
         else if (txtWarehouseID.Text.Trim() == "")
         {
             MessageBox.Show("仓库编号不能为空!", "提示");
             txtWarehouseID.Focus();
             return;
         }
         else if (txtCity.Text.Trim() == "")
         {
             MessageBox.Show("所在城市不能为空!", "提示");
             txtCity.Focus();
             return;
         }
         else if (txtPhone.Text.Trim() == "")
         {
             MessageBox.Show("联系电话不能为空!", "提示");
             txtPhone.Focus();
             return;
         }
         else if (txtRent.Text.Trim() == "")
         {
             MessageBox.Show("每月租金不能为空!", "提示");
             txtRent.Focus();
             return;
         }
         else if (!No(txtWarehouseID.Text.Trim()))
         {
             MessageBox.Show("该仓库已存在!", "提示");
             ClearAll();
             return;
         }
         else
         {
             btnAdd.Text = "添加";
             string sqlStr = "insert into tbl_Warehouse values('" + txtWarehouseID.Text.Trim() + "','" +
                             txtCity.Text.Trim() + "','" + txtPhone.Text.Trim() + "','" + txtRent.Text.Trim() + "')";
             CDataBase.UpdateDB(sqlStr);
             RefreshData("select * from tbl_Warehouse");
             ClearAll();
             ObjClose();
         }
     }
     catch (Exception ex)
     {
         CDataBase.conn.Close();
         MessageBox.Show(ex.Message);
         ClearAll();
         ObjClose();
     }
 }
Beispiel #6
0
 private void btnDelete_Click(object sender, EventArgs e)
 {
     try
     {
         if (txtBookID.Text.Trim() == "")
         {
             MessageBox.Show("没有可删除的记录!", "提示");
             return;
         }
         string sqlStr1 = "select * from tbl_ShoppingBasket where bookID='" + txtBookID.Text.Trim() + "'";
         string sqlStr2 = "select * from tbl_OrderForm where bookID='" + txtBookID.Text.Trim() + "'";
         string sqlStr3 = "select * from tbl_ImportList where bookID='" + txtBookID.Text.Trim() + "'";
         string sqlStr4 = "select * from tbl_Stocks where bookID='" + txtBookID.Text.Trim() + "'";
         if (CDataBase.GetDataFromDB(sqlStr1) != null)
         {
             MessageBox.Show("顾客购物篮中存在这本书,不能删除该书!", "删除出错", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
         else if (CDataBase.GetDataFromDB(sqlStr2) != null)
         {
             MessageBox.Show("顾客订单中存在这本书,不能删除该书!", "删除出错", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
         else if (CDataBase.GetDataFromDB(sqlStr3) != null)
         {
             MessageBox.Show("进货清单中存在这本书,不能删除该书!", "删除出错", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
         else if (CDataBase.GetDataFromDB(sqlStr4) != null)
         {
             string sqlStr5 = "delete from tbl_Stocks where bookID='" + txtBookID.Text.Trim() + "'";
             CDataBase.UpdateDB(sqlStr5);
         }
         else if (MessageBox.Show("确定要删除书籍“" + txtTitle.Text.Trim() + "”吗?", "删除书籍",
                                  MessageBoxButtons.YesNo, MessageBoxIcon.Question,
                                  MessageBoxDefaultButton.Button2) == DialogResult.Yes)
         {
             string sqlStr = "delete from tbl_Book where bookID='" + txtBookID.Text.Trim() + "'";
             CDataBase.UpdateDB(sqlStr);
             int n = dgrdvBook.CurrentCell.RowIndex;
             dgrdvBook.Rows.RemoveAt(n);
             if (dgrdvBook.Rows.Count == 1)
             {
                 ClearAll();
                 dgrdvBook.DataSource = null;
             }
             else
             {
                 dgrdvBook_RowHeaderMouseClick(null, null);
             }
         }
     }
     catch (Exception ex)
     {
         CDataBase.conn.Close();
         MessageBox.Show(ex.Message);
     }
 }
Beispiel #7
0
 private void btnUpdate_Click(object sender, EventArgs e)
 {
     try
     {
         if (btnUpdate.Text.Trim() == "修改")
         {
             btnUpdate.Text    = "确定";
             btnAdd.Enabled    = false;
             btnDelete.Enabled = false;
             btnClose.Enabled  = false;
             cmbSelect.Enabled = false;
             txtSelect.Enabled = false;
             btnSelect.Enabled = false;
             btnAll.Enabled    = false;
             btnUp.Enabled     = false;
             btnDown.Enabled   = false;
             dgrdvBook.Enabled = false;
             ObjUpdateOpen();
         }
         else
         {
             btnUpdate.Text    = "修改";
             btnAdd.Enabled    = true;
             btnDelete.Enabled = true;
             btnClose.Enabled  = true;
             cmbSelect.Enabled = true;
             txtSelect.Enabled = true;
             btnSelect.Enabled = true;
             btnAll.Enabled    = true;
             btnUp.Enabled     = true;
             btnDown.Enabled   = true;
             dgrdvBook.Enabled = true;
             ObjClose();
             double retail = Convert.ToDouble(txtRetail.Text.Trim());
             double import = Convert.ToDouble(txtImport.Text.Trim());
             string sqlStr;
             sqlStr = "update tbl_Book set bookID='" + txtBookID.Text.Trim() + "',ISBN='" +
                      txtISBN.Text.Trim() + "',title='" + txtTitle.Text.Trim() + "',bookAuthor='" +
                      txtAuthor.Text.Trim() + "',bookPublisher='" + txtPublisher.Text.Trim() + "',year='" +
                      txtYear.Text.Trim() + "',retailPrice =" + retail + " ,importPrice =" +
                      import + " ,profit = " + (retail - import) + " ,profitRate = " +
                      ((retail - import) / import) + " ,discountRate = " + TDouble(txtDiscount.Text.Trim()) +
                      " where bookID='" + txtBookID.Text.Trim() + "'";
             CDataBase.UpdateDB(sqlStr);
             bool b = RefreshData("select * from tbl_Book");
         }
     }
     catch (Exception ex)
     {
         CDataBase.conn.Close();
         MessageBox.Show(ex.Message);
     }
 }
Beispiel #8
0
        void InsertAdminInfo()
        {
            CDataBase.conn.ConnectionString = CDataBase.connStr;
            string psw     = CPublic.GetMd5Str(txtSAPassword.Text.Trim());
            string sqlStr1 = "insert into tbl_User values('" + txtSuperAdmin.Text.Trim() + "','" + psw.Trim() + "','超级管理员','是')";
            string sqlStr2 = "insert into tbl_Admin values('" + txtSuperAdmin.Text.Trim() + "','" +
                             txtSuperName.Text.Trim() + "','" + "000" + "','" + cmbSuperSex.Text.Trim() + "','" +
                             txtSuperAge.Text.Trim() + "','" + "超级管理员" + "','" + "2014-01-01" + "','" + "10000" + "')";

            if (CDataBase.UpdateDB(sqlStr1) && CDataBase.UpdateDB(sqlStr2))
            {
                MessageBox.Show("超级管理员: " + txtSuperAdmin.Text + " 注册成功!");
            }
        }
 private void btnOK_Click(object sender, EventArgs e)
 {
     try
     {
         startDateString = dtpStartDate.Value.ToString("yyyy-MM-dd");
         if (txtName.Text.Trim() == "")
         {
             MessageBox.Show("姓名不能为空", "提示");
             txtName.Focus();
         }
         else if (txtJobID.Text.Trim() == "")
         {
             MessageBox.Show("工号不能为空", "提示");
             txtJobID.Focus();
         }
         else if (txtAge.Text.Trim() == "")
         {
             MessageBox.Show("年龄不能为空", "提示");
             txtAge.Focus();
         }
         else if (int.Parse(txtAge.Text.Trim()) <= 0)
         {
             MessageBox.Show("年龄必须大于零", "提示");
         }
         else if (txtSalaryPerMonth.Text.Trim() == "")
         {
             MessageBox.Show("月薪不能为空", "提示");
             txtSalaryPerMonth.Focus();
         }
         else
         {
             string sqlStr = "insert into tbl_Admin values('" + txtUserName.Text.Trim() + "','" +
                             txtName.Text.Trim() + "','" + txtJobID.Text.Trim() + "','" + cmbSex.Text.Trim() + "','" +
                             txtAge.Text.Trim() + "','" + "普通管理员" + "','" + startDateString + "','" +
                             txtSalaryPerMonth.Text.Trim() + "')";
             if (CDataBase.UpdateDB(sqlStr))
             {
                 MessageBox.Show("普通管理员:" + txtUserName.Text + " 信息完善成功!", "完善用户信息");
             }
             this.Close();
         }
     }
     catch (Exception ex)
     {
         CDataBase.conn.Close();
         MessageBox.Show(ex.Message);
         this.Close();
     }
 }
Beispiel #10
0
 private void btnClose_Click(object sender, EventArgs e)
 {
     try
     {
         string sqlStr = "delete from tbl_ShoppingBasket where basketStatus = '已付款' or basketStatus ='已删除'";
         if (CDataBase.UpdateDB(sqlStr))
         {
             this.Close();
         }
     }
     catch (Exception ex)
     {
         CDataBase.conn.Close();
         MessageBox.Show(ex.Message);
     }
 }
Beispiel #11
0
 private void btnAddToBasket_Click(object sender, EventArgs e)
 {
     try
     {
         if (dgrdvBookCity.DataSource == null)
         {
             MessageBox.Show("没有能够添加到购物篮的书籍!", "提示");
             return;
         }
         if (nupNumber.Value < 1)
         {
             MessageBox.Show("请输入要选购的数量!", "提示");
             nupNumber.Focus();
             return;
         }
         int    n           = dgrdvBookCity.CurrentCell.RowIndex;
         string warehouseID = dgrdvBookCity[0, n].Value.ToString().Trim();
         string bookID      = dgrdvBookCity[1, n].Value.ToString().Trim();
         int    m           = dgrdvBasket.RowCount - 1;
         for (int i = 0; i < m; i++)
         {
             if (dgrdvBasket[0, i].Value.ToString().Trim() == warehouseID &&
                 dgrdvBasket[1, i].Value.ToString().Trim() == bookID &&
                 dgrdvBasket[7, i].Value.ToString().Trim() == "未付款")
             {
                 MessageBox.Show("购物篮中已经存在该书,请更改购物篮数量!", "提示");
                 nupNumberUpdate.Focus();
                 return;
             }
         }
         string sqlStr = "insert into tbl_ShoppingBasket values('" + bookID + "','" + warehouseID + "','" +
                         CPublic.userInfo[0] + "', " + (int)nupNumber.Value + " , " + "'未付款')";
         CDataBase.UpdateDB(sqlStr);
         sqlStr = "delete from tbl_ShoppingBasket where basketStatus = '已付款' or basketStatus ='已删除'";
         CDataBase.UpdateDB(sqlStr);
         RefreshBasketData();
         MessageBox.Show("添加到购物篮成功!", "提示");
         btnPay.Enabled    = true;
         nupNumber.Enabled = false;
         nupNumber.Value   = 0;
     }
     catch (Exception ex)
     {
         CDataBase.conn.Close();
         MessageBox.Show(ex.Message);
     }
 }
Beispiel #12
0
 private void btnUpdate_Click(object sender, EventArgs e)
 {
     try
     {
         if (txtName1.Text.Trim() == "")
         {
             MessageBox.Show("姓名不能为空", "提示");
             txtName1.Focus();
         }
         else if (txtStartDate.Text.Trim() == "")
         {
             MessageBox.Show("入职日期不能为空", "提示");
             txtStartDate.Focus();
         }
         else if (txtAge.Text.Trim() == "")
         {
             MessageBox.Show("年龄不能为空", "提示");
             txtAge.Focus();
         }
         else if (txtSalary.Text.Trim() == "")
         {
             MessageBox.Show("月薪不能为空", "提示");
             txtSalary.Focus();
         }
         else
         {
             string sqlStr = "update tbl_Admin set adminName='" + txtName1.Text.Trim() + "',adminAge='"
                             + txtAge.Text.Trim() + "',startDate='" + txtStartDate.Text.Trim() + "',salaryPerMonth='"
                             + txtSalary.Text.Trim() + "' where adminUserName='******'";
             if (CDataBase.UpdateDB(sqlStr))
             {
                 MessageBox.Show("修改个人信息成功!", "恭喜");
                 adminName   = txtName1.Text;
                 startDate   = txtStartDate.Text;
                 adminAge    = txtAge.Text;
                 adminSalary = txtSalary.Text;
             }
         }
     }
     catch (Exception ex)
     {
         CDataBase.conn.Close();
         MessageBox.Show(ex.Message);
         this.Close();
     }
 }
Beispiel #13
0
 private void btnChagePassword_Click(object sender, EventArgs e)
 {
     try
     {
         if (CPublic.GetMd5Str(txtOldPassword.Text.Trim()) != CPublic.userInfo[1])
         {
             MessageBox.Show("旧密码错误,请重新输入", "提示");
             txtOldPassword.Text  = "";
             txtNewPassword1.Text = "";
             txtNewPassword2.Text = "";
             txtOldPassword.Focus();
         }
         else if (txtNewPassword1.Text.Trim() == "" && txtNewPassword2.Text.Trim() == "")
         {
             MessageBox.Show("密码不能为空", "提示");
             txtNewPassword1.Focus();
         }
         else if (txtNewPassword1.Text.Trim() == txtNewPassword2.Text.Trim())
         {
             string psw    = CPublic.GetMd5Str(txtNewPassword1.Text.Trim());
             string sqlStr = "update tbl_User set userPassword='******' where userName='******'";
             if (CDataBase.UpdateDB(sqlStr))
             {
                 CPublic.userInfo[1] = psw.Trim();
                 MessageBox.Show("修改成功,请记住您的新密码", "修改密码");
                 txtOldPassword.Text  = "";
                 txtNewPassword1.Text = "";
                 txtNewPassword2.Text = "";
             }
         }
         else
         {
             MessageBox.Show("两次输入的密码不一致", "提示");
             txtNewPassword1.Text = "";
             txtNewPassword2.Text = "";
             txtNewPassword1.Focus();
         }
     }
     catch (Exception ex)
     {
         CDataBase.conn.Close();
         MessageBox.Show(ex.Message);
     }
 }
Beispiel #14
0
 private void btnDelete_Click(object sender, EventArgs e)
 {
     try
     {
         int    n           = dgrdvWarehouse.CurrentCell.RowIndex;
         string warehouseID = dgrdvWarehouse[0, n].Value.ToString().Trim();
         string sqlStr1     = "select * from tbl_ImportList where warehouseID='" + warehouseID + "'";
         string sqlStr2     = "select * from tbl_Stocks where warehouseID='" + warehouseID + "'";
         if (CDataBase.GetDataFromDB(sqlStr1) != null)
         {
             MessageBox.Show("进货清单中存在该仓库,不能删除该仓库!", "删除出错", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
         else if (CDataBase.GetDataFromDB(sqlStr2) != null)
         {
             MessageBox.Show("该仓库中仍有书籍库存,不能删除该仓库!", "删除出错", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
         else if (MessageBox.Show("确定要删除仓库“" + warehouseID + "”吗?", "删除仓库",
                                  MessageBoxButtons.YesNo, MessageBoxIcon.Question,
                                  MessageBoxDefaultButton.Button2) == DialogResult.Yes)
         {
             string sqlStr = "delete from tbl_Warehouse where warehouseID='" + warehouseID + "'";
             CDataBase.UpdateDB(sqlStr);
             int m = dgrdvWarehouse.CurrentCell.RowIndex;
             dgrdvWarehouse.Rows.RemoveAt(m);
             if (dgrdvWarehouse.Rows.Count == 1)
             {
                 ClearAll();
                 dgrdvWarehouse.DataSource = null;
             }
             else
             {
                 dgrdvWarehouse_RowHeaderMouseClick(null, null);
             }
         }
     }
     catch (Exception ex)
     {
         CDataBase.conn.Close();
         MessageBox.Show(ex.Message);
     }
 }
Beispiel #15
0
 private void btnUpdate_Click(object sender, EventArgs e)
 {
     try
     {
         if (txtName1.Text.Trim() == "")
         {
             MessageBox.Show("姓名不能为空", "提示");
             txtName1.Focus();
         }
         else if (txtPhone.Text.Trim() == "")
         {
             MessageBox.Show("电话不能为空", "提示");
             txtPhone.Focus();
         }
         else if (txtAddress.Text.Trim() == "")
         {
             MessageBox.Show("地址不能为空", "提示");
             txtAddress.Focus();
         }
         else
         {
             string sqlStr = "update tbl_Customer set customerName='" + txtName1.Text.Trim() + "',customerPhone='"
                             + txtPhone.Text.Trim() + "',customerAddress='" + txtAddress.Text.Trim() + "',balance='"
                             + txtBalance.Text.Trim() + "' where customerEmail='" + CPublic.userInfo[0] + "'";
             if (CDataBase.UpdateDB(sqlStr))
             {
                 MessageBox.Show("修改个人信息成功!", "恭喜");
                 customerName = txtName1.Text;
                 balance      = txtBalance.Text;
             }
         }
     }
     catch (Exception ex)
     {
         CDataBase.conn.Close();
         MessageBox.Show(ex.Message);
         this.Close();
     }
 }
Beispiel #16
0
 private void btnUpdateNumber_Click(object sender, EventArgs e)
 {
     try
     {
         int    n           = dgrdvBasket.CurrentCell.RowIndex;
         string warehouseID = dgrdvBasket[0, n].Value.ToString().Trim();
         string bookID      = dgrdvBasket[1, n].Value.ToString().Trim();
         if (MessageBox.Show("确定将数量更改为" + nupNumberUpdate.Value.ToString().Trim() + "吗 ?", "删除购物篮",
                             MessageBoxButtons.YesNo, MessageBoxIcon.Question,
                             MessageBoxDefaultButton.Button2) == DialogResult.Yes)
         {
             string sqlStr = "update tbl_ShoppingBasket set basketNumber = " + (int)nupNumberUpdate.Value +
                             " where warehouseID='" + warehouseID + "' and bookID='" + bookID + "' and basketStatus ='未付款'";
             CDataBase.UpdateDB(sqlStr);
             RefreshBasketData();
         }
     }
     catch (Exception ex)
     {
         CDataBase.conn.Close();
         MessageBox.Show(ex.Message);
     }
 }
Beispiel #17
0
 private void btnOK_Click(object sender, EventArgs e)
 {
     try
     {
         if (txtName.Text.Trim() == "")
         {
             MessageBox.Show("姓名不能为空", "提示");
             txtName.Focus();
         }
         else if (txtPhone.Text.Trim() == "")
         {
             MessageBox.Show("电话不能为空", "提示");
             txtPhone.Focus();
         }
         else if (txtAddress.Text.Trim() == "")
         {
             MessageBox.Show("地址不能为空", "提示");
             txtAddress.Focus();
         }
         else
         {
             string sqlStr = "insert into tbl_Customer values('" + txtUserName.Text.Trim() + "','" +
                             txtName.Text.Trim() + "','" + txtPhone.Text.Trim() + "','" + txtAddress.Text.Trim() + "','" + "10000.00" + "')";
             if (CDataBase.UpdateDB(sqlStr))
             {
                 MessageBox.Show("顾客:" + txtUserName.Text + " 信息完善成功!", "完善用户信息");
             }
             this.Close();
         }
     }
     catch (Exception ex)
     {
         CDataBase.conn.Close();
         MessageBox.Show(ex.Message);
         this.Close();
     }
 }
Beispiel #18
0
 private void btnReturn_Click(object sender, EventArgs e)
 {
     try
     {
         int    n            = dgrdvImportList.CurrentCell.RowIndex;
         string warehouseID  = dgrdvImportList[0, n].Value.ToString().Trim();
         string bookID       = dgrdvImportList[2, n].Value.ToString().Trim();
         string generateDate = dgrdvImportList[7, n].Value.ToString().Trim();
         if (MessageBox.Show("确定要退货吗?", "退货",
                             MessageBoxButtons.YesNo, MessageBoxIcon.Question,
                             MessageBoxDefaultButton.Button2) == DialogResult.Yes)
         {
             string sqlStr = "update tbl_ImportList set status = '已退货' where warehouseID='" + warehouseID +
                             "' and bookID='" + bookID + "' and generateDateTime='" + generateDate + "'";
             CDataBase.UpdateDB(sqlStr);
             RefreshImportData();
         }
     }
     catch (Exception ex)
     {
         CDataBase.conn.Close();
         MessageBox.Show(ex.Message);
     }
 }
Beispiel #19
0
 private void btnAdd_Click(object sender, EventArgs e)
 {
     try
     {
         if (btnAdd.Text.Trim() == "添加")
         {
             btnAdd.Text = "确定";
             ObjAddOpen();
             bool a = RefreshData("select * from tbl_Book");
             ClearAll();
             txtDiscount.Text  = "%形式";
             btnUpdate.Enabled = false;
             btnDelete.Enabled = false;
             cmbSelect.Enabled = false;
             txtSelect.Enabled = false;
             btnSelect.Enabled = false;
             btnAll.Enabled    = false;
             btnUp.Enabled     = false;
             btnDown.Enabled   = false;
             dgrdvBook.Enabled = false;
             return;
         }
         else if (txtBookID.Text.Trim() == "")
         {
             MessageBox.Show("书籍编号不能为空!", "提示");
             txtBookID.Focus();
             return;
         }
         else if (txtISBN.Text.Trim() == "")
         {
             MessageBox.Show("ISBN不能为空!", "提示");
             txtISBN.Focus();
             return;
         }
         else if (txtTitle.Text.Trim() == "")
         {
             MessageBox.Show("书名不能为空!", "提示");
             txtTitle.Focus();
             return;
         }
         else if (txtAuthor.Text == "")
         {
             MessageBox.Show("作者不能为空!", "提示");
             txtAuthor.Focus();
             return;
         }
         else if (txtPublisher.Text.Trim() == "")
         {
             MessageBox.Show("出版社不能为空!", "提示");
             txtPublisher.Focus();
             return;
         }
         else if (txtYear.Text.Trim() == "")
         {
             MessageBox.Show("出版年份不能为空!", "提示");
             txtYear.Focus();
             return;
         }
         else if (txtRetail.Text.Trim() == "")
         {
             MessageBox.Show("零售价不能为空!", "提示");
             txtRetail.Focus();
             return;
         }
         else if (txtImport.Text.Trim() == "")
         {
             MessageBox.Show("进货价不能为空!", "提示");
             txtImport.Focus();
             return;
         }
         else if (txtDiscount.Text.Trim() == "")
         {
             MessageBox.Show("折扣信息不能为空!", "提示");
             txtDiscount.Focus();
             return;
         }
         else if (!No(txtBookID.Text.Trim()))
         {
             MessageBox.Show("该书已存在!", "提示");
             ClearAll();
             return;
         }
         btnAdd.Text = "添加";
         double retail = Convert.ToDouble(txtRetail.Text.Trim());
         double import = Convert.ToDouble(txtImport.Text.Trim());
         string sqlStr = "insert into tbl_Book values('" + txtBookID.Text.Trim() + "','"
                         + txtISBN.Text.Trim() + "','" + txtTitle.Text.Trim() + "','" + txtAuthor.Text.Trim() + "','"
                         + txtPublisher.Text.Trim() + "','" + txtYear.Text.Trim() + "','" + txtRetail.Text.Trim() + "','"
                         + txtImport.Text.Trim() + "', " + (retail - import) + " , " + ((retail - import) / import)
                         + " , '" + TDouble(txtDiscount.Text.Trim()) + "')";
         CDataBase.UpdateDB(sqlStr);
         bool b = RefreshData("select * from tbl_Book");
         if (MessageBox.Show("添加成功!继续添加吗?", "添加书籍", MessageBoxButtons.YesNo,
                             MessageBoxIcon.Question, MessageBoxDefaultButton.Button1) == DialogResult.Yes)
         {
             ClearAll();
             ObjAddOpen();
             btnAdd.Text = "确定";
         }
         else
         {
             ObjClose();
             btnUpdate.Enabled = true;
             btnDelete.Enabled = true;
             btnClose.Enabled  = true;
             cmbSelect.Enabled = true;
             txtSelect.Enabled = true;
             btnSelect.Enabled = true;
             btnAll.Enabled    = true;
             dgrdvBook.Enabled = true;
         }
     }
     catch (Exception ex)
     {
         CDataBase.conn.Close();
         MessageBox.Show(ex.Message);
         ClearAll();
         ObjClose();
         btnUpdate.Enabled = true;
         btnDelete.Enabled = true;
         btnClose.Enabled  = true;
         cmbSelect.Enabled = true;
         txtSelect.Enabled = true;
         btnSelect.Enabled = true;
         btnAll.Enabled    = true;
         dgrdvBook.Enabled = true;
         dgrdvBook_RowHeaderMouseClick(null, null);
     }
 }
Beispiel #20
0
 private void btnSetPswPctQuestion_Click(object sender, EventArgs e)
 {
     try
     {
         if (txtName.Enabled == false)
         {
             txtName.Enabled    = true;
             txtAnswer1.Enabled = true;
             txtAnswer2.Enabled = true;
             txtAnswer3.Enabled = true;
             txtName.Focus();
             btnSetPswPctQuestion.Text = "确定";
         }
         else
         {
             if (txtName.Text.Trim() == "")
             {
                 MessageBox.Show("姓名不能为空", "提示");
                 txtName.Focus();
                 return;
             }
             else if (txtAnswer1.Text.Trim() == "")
             {
                 MessageBox.Show("请输入第一个问题的答案", "提示");
                 txtAnswer1.Focus();
                 return;
             }
             else if (txtAnswer2.Text.Trim() == "")
             {
                 MessageBox.Show("请输入第二个问题的答案", "提示");
                 txtAnswer2.Focus();
                 return;
             }
             else if (txtAnswer3.Text.Trim() == "")
             {
                 MessageBox.Show("请输入第三个问题的答案", "提示");
                 txtAnswer3.Focus();
                 return;
             }
             string sqlStr;
             if (set)
             {
                 sqlStr = "insert into tbl_Information values('" + CPublic.userInfo[0] + "','" +
                          txtName.Text.Trim() + "','" + txtAnswer1.Text.Trim() + "','" + txtAnswer2.Text.Trim()
                          + "','" + txtAnswer3.Text.Trim() + "')";
                 if (CDataBase.UpdateDB(sqlStr))
                 {
                     MessageBox.Show("设置密保问题成功", "恭喜");
                     set    = false;
                     sqlStr = "update tbl_User set firstLogin='******' where userName='******'";
                     CDataBase.UpdateDB(sqlStr);
                 }
             }
             else
             {
                 sqlStr = "update tbl_Information set name='" + txtName.Text.Trim() + "',Answer1='"
                          + txtAnswer1.Text.Trim() + "',Answer2='" + txtAnswer2.Text.Trim() + "',Answer3='"
                          + txtAnswer3.Text.Trim() + "' where userName='******'";
                 if (CDataBase.UpdateDB(sqlStr))
                 {
                     MessageBox.Show("修改密保问题成功", "恭喜");
                 }
             }
             btnSetPswPctQuestion.Text = "设置密保问题";
             txtName.Text                    = "";
             txtAnswer1.Text                 = "";
             txtAnswer2.Text                 = "";
             txtAnswer3.Text                 = "";
             txtName.Enabled                 = false;
             txtBalance.Enabled              = false;
             txtAnswer1.Enabled              = false;
             txtAnswer2.Enabled              = false;
             txtAnswer3.Enabled              = false;
             btnSetPswPctQuestion.Enabled    = false;
             btnDeletePswPctQuestion.Enabled = false;
         }
     }
     catch (Exception ex)
     {
         CDataBase.conn.Close();
         MessageBox.Show(ex.Message);
     }
 }
 private void btnOK_Click(object sender, EventArgs e)
 {
     try
     {
         if (txtUserName.Text.Trim() == "")
         {
             MessageBox.Show("注册邮箱不能为空", "提示");
             txtUserName.Focus();
         }
         else if (!UserName(txtUserName.Text.Trim()))
         {
             MessageBox.Show("该用户已存在!", "提示");
             txtUserName.Text = "";
             txtUserName.Focus();
         }
         else if (txtName.Text.Trim() == "")
         {
             MessageBox.Show("姓名不能为空", "提示");
             txtName.Focus();
         }
         else if (txtPhone.Text.Trim() == "")
         {
             MessageBox.Show("电话不能为空", "提示");
             txtPhone.Focus();
         }
         else if (txtAddress.Text.Trim() == "")
         {
             MessageBox.Show("地址不能为空", "提示");
             txtAddress.Focus();
         }
         else if (txtPassword.Text.Trim() == "" && txtComfirmPassword.Text.Trim() == "")
         {
             MessageBox.Show("密码不能为空", "提示");
             txtPassword.Focus();
         }
         else if (txtPassword.Text.Trim() != txtComfirmPassword.Text.Trim())
         {
             MessageBox.Show("两次密码不一致", "提示");
             txtPassword.Text        = "";
             txtComfirmPassword.Text = "";
             txtPassword.Focus();
         }
         else
         {
             string sqlStr1 = "insert into tbl_User values('" + txtUserName.Text.Trim() + "','" +
                              CPublic.GetMd5Str(txtPassword.Text.Trim()) + "','" + "顾客" + "','" + "是" + "')";
             string sqlStr2 = "insert into tbl_Customer values('" + txtUserName.Text.Trim() + "','" +
                              txtName.Text.Trim() + "','" + txtPhone.Text.Trim() + "','" + txtAddress.Text.Trim() + "','" + "10000.00" + "')";
             if (CDataBase.UpdateDB(sqlStr1) && CDataBase.UpdateDB(sqlStr2))
             {
                 MessageBox.Show("顾客:" + txtUserName.Text + " 注册成功!", "恭喜");
             }
             this.Close();
         }
     }
     catch (Exception ex)
     {
         CDataBase.conn.Close();
         MessageBox.Show(ex.Message);
         this.Close();
     }
 }
Beispiel #22
0
 private void btnRegedit_Click(object sender, EventArgs e)
 {
     try
     {
         if (btnRegedit.Text == "注册")
         {
             btnRegedit.Text   = "确定";
             btnCancel.Enabled = true;
             ObjOpen();
         }
         else if (txtUserName.Text.Trim() == "")
         {
             MessageBox.Show("用户名不能为空", "提示");
             txtUserName.Focus();
         }
         else if (txtPassword.Text.Trim() == "")
         {
             MessageBox.Show("密码不能为空", "提示");
             txtPassword.Focus();
         }
         else if (!UserNameExist(txtUserName.Text.Trim()))
         {
             MessageBox.Show("该用户已存在!", "提示");
             txtUserName.Text = "";
             txtPassword.Text = "";
             ObjOpen();
             btnRegedit.Text = "注册";
             txtUserName.Focus();
         }
         else
         {
             btnRegedit.Text = "注册";
             string psw    = CPublic.GetMd5Str(txtPassword.Text.Trim());
             string sqlStr = "insert into tbl_User values('" + txtUserName.Text.Trim() + "','" +
                             psw.Trim() + "','" + cmbPurview.Text.Trim() + "','是')";
             string regType = cmbPurview.Text.Trim();
             if (CDataBase.UpdateDB(sqlStr))
             {
                 MessageBox.Show(cmbPurview.Text + " " + txtUserName.Text + " 注册成功!\n" +
                                 "请进一步完善用户信息", "注册用户");
             }
             CPublic.userName = txtUserName.Text.Trim();
             if (regType == "普通管理员")
             {
                 if (ob_FrmCompleteAdminInfo == null || ob_FrmCompleteAdminInfo.IsDisposed)
                 {
                     ob_FrmCompleteAdminInfo = new FrmCompleteAdminInfo();
                     ob_FrmCompleteAdminInfo.Show();
                 }
                 else
                 {
                     ob_FrmCompleteAdminInfo.Activate();
                 }
             }
             else if (regType == "顾客")
             {
                 if (ob_FrmCompleteCustomerInfo == null || ob_FrmCompleteCustomerInfo.IsDisposed)
                 {
                     ob_FrmCompleteCustomerInfo = new FrmCompleteCustomerInfo();
                     ob_FrmCompleteCustomerInfo.Show();
                 }
                 else
                 {
                     ob_FrmCompleteCustomerInfo.Activate();
                 }
             }
             ClearAll();
             ObjClose();
             btnCancel.Enabled = false;
         }
     }
     catch (Exception ex)
     {
         CDataBase.conn.Close();
         MessageBox.Show(ex.Message);
         ClearAll();
         ObjClose();
         btnCancel.Enabled = false;
     }
 }
Beispiel #23
0
 private void btnPay_Click(object sender, EventArgs e)
 {
     try
     {
         double   totalPay = 0.0;
         double   Price;
         double   discount;
         int      Amount;
         int      stockAmount;
         int      rowNum       = dgrdvBasket.RowCount - 1;
         DateTime dtFinance    = System.DateTime.Now;
         string   generateDate = dtFinance.ToString().Trim();
         for (int i = 0; i < rowNum; i++)
         {
             Price       = Convert.ToDouble(dgrdvBasket[3, i].Value.ToString().Trim());
             discount    = Convert.ToDouble(dgrdvBasket[5, i].Value.ToString().Trim());
             Amount      = Convert.ToInt32(dgrdvBasket[4, i].Value.ToString().Trim());
             stockAmount = Convert.ToInt32(dgrdvBasket[6, i].Value.ToString().Trim());
             if (Amount > stockAmount)
             {
                 MessageBox.Show("书籍:" + dgrdvBasket[2, i].Value.ToString().Trim() + " 库存不足\n     请更改数量!", "提示");
                 nupNumberUpdate.Enabled = true;
                 nupNumberUpdate.Focus();
                 return;
             }
             if (dgrdvBasket[7, i].Value.ToString().Trim() == "未付款")
             {
                 totalPay += (Price * Amount * discount);
             }
         }
         if (totalPay == 0.0)
         {
             MessageBox.Show("当前没有购物篮需要付款!", "提示");
             return;
         }
         if (MessageBox.Show("购物篮付款总额为:" + totalPay.ToString() + "元\n       确定要付款吗?", "购物篮付款",
                             MessageBoxButtons.YesNo, MessageBoxIcon.Question,
                             MessageBoxDefaultButton.Button2) == DialogResult.Yes)
         {
             int     rowNum1 = dgrdvBasket.RowCount - 1;
             string  sqlStr3, sqlStr4, sqlStr5, sqlStr6, warehouseID, bookID;
             int     Number;
             DataSet ds = new DataSet();
             sqlStr6 = "select balance from tbl_Customer where customerEmail='" + CPublic.userInfo[0] + "'";
             ds      = CDataBase.GetDataFromDB(sqlStr6);
             double balance = Convert.ToDouble(ds.Tables[0].Rows[0].ItemArray[0].ToString().Trim());
             if (balance < totalPay)
             {
                 MessageBox.Show("您的余额不足,未能完成付款!", "很遗憾");
                 return;
             }
             sqlStr3 = "update tbl_Customer set balance = balance - " + totalPay +
                       " where customerEmail ='" + CPublic.userInfo[0] + "'";
             CDataBase.UpdateDB(sqlStr3);
             for (int i = 0; i < rowNum1; i++)
             {
                 if (dgrdvBasket[7, i].Value.ToString().Trim() == "未付款")
                 {
                     warehouseID = dgrdvBasket[0, i].Value.ToString().Trim();
                     bookID      = dgrdvBasket[1, i].Value.ToString().Trim();
                     Number      = Convert.ToInt32(dgrdvBasket[4, i].Value.ToString().Trim());
                     sqlStr4     = "update tbl_Stocks set leftAmount = leftAmount - " + Number +
                                   " , soldAmount = soldAmount + " + Number +
                                   " where warehouseID='" + warehouseID + "' and bookID='" + bookID + "'";
                     CDataBase.UpdateDB(sqlStr4);
                     sqlStr5 = "insert into tbl_OrderForm values ('" + bookID + "','" + CPublic.userInfo[0] +
                               "', " + Number + " ,'" + generateDate + "', '未出库' )";
                     CDataBase.UpdateDB(sqlStr5);
                 }
             }
             string sqlStr1;
             sqlStr1 = "update tbl_ShoppingBasket set basketStatus = '已付款' where basketStatus = '未付款' ";
             CDataBase.UpdateDB(sqlStr1);
             RefreshBasketData();
             string financeID = generateDate.Replace('/', '0').Replace(' ', '0').Replace(':', '0');
             sqlStr1 = "insert into tbl_Finance values('" + financeID + "', " + totalPay + " , '进账' , '" +
                       CPublic.userInfo[0] + "', '" + generateDate + "')";
             CDataBase.UpdateDB(sqlStr1);
             btnPay.Enabled    = false;
             btnDelete.Enabled = false;
             RefreshBookData(publicSqlString);
         }
     }
     catch (Exception ex)
     {
         CDataBase.conn.Close();
         MessageBox.Show(ex.Message);
     }
 }
Beispiel #24
0
 private void btnPay_Click(object sender, EventArgs e)
 {
     try
     {
         double totalPay = 0.0;
         double importPrice;
         int    importAmount;
         int    rowNum = dgrdvImportList.RowCount - 1;
         for (int i = 0; i < rowNum; i++)
         {
             importPrice  = Convert.ToDouble(dgrdvImportList[4, i].Value.ToString().Trim());
             importAmount = Convert.ToInt32(dgrdvImportList[5, i].Value.ToString().Trim());
             if (dgrdvImportList[6, i].Value.ToString().Trim() == "未付款")
             {
                 totalPay += (importPrice * importAmount);
             }
         }
         if (totalPay == 0.0)
         {
             MessageBox.Show("当前没有订货清单需要付款!", "提示");
             return;
         }
         if (MessageBox.Show("订货清单付款总额为:" + totalPay.ToString() + "元\n       确定要付款吗?", "订货清单付款",
                             MessageBoxButtons.YesNo, MessageBoxIcon.Question,
                             MessageBoxDefaultButton.Button2) == DialogResult.Yes)
         {
             string sqlStr1, sqlStr2;
             sqlStr1 = "update tbl_ImportList set status = '已付款' where status = '未付款' ";
             CDataBase.UpdateDB(sqlStr1);
             RefreshImportData();
             int    rowNum1 = dgrdvImportList.RowCount - 1;
             string sqlStr3, sqlStr4, warehouseID, bookID;
             double importPrice1;
             int    importNumber;
             for (int i = 0; i < rowNum1; i++)
             {
                 if (dgrdvImportList[6, i].Value.ToString().Trim() == "已付款")
                 {
                     warehouseID  = dgrdvImportList[0, i].Value.ToString().Trim();
                     bookID       = dgrdvImportList[2, i].Value.ToString().Trim();
                     importPrice1 = Convert.ToDouble(dgrdvImportList[4, i].Value.ToString().Trim());
                     importNumber = Convert.ToInt32(dgrdvImportList[5, i].Value.ToString().Trim());
                     sqlStr3      = "update tbl_Book set importPrice = " + importPrice1 + ", profit = retailPrice - " + importPrice1 +
                                    " , profitRate = (retailPrice-" + importPrice1 + ")/" + importPrice1 + " where bookID='" +
                                    bookID + "'";
                     sqlStr4 = "update tbl_Stocks set leftAmount = leftAmount + " + importNumber +
                               " where warehouseID='" + warehouseID + "' and bookID='" + bookID + "'";
                     if (!CDataBase.UpdateDB(sqlStr3) || !CDataBase.UpdateDB(sqlStr4))
                     {
                         MessageBox.Show("添加库存失败!", "警告");
                         return;
                     }
                 }
             }
             DateTime dtFinance    = System.DateTime.Now;
             string   generateDate = dtFinance.ToString().Trim();
             string   financeID    = generateDate.Replace('/', '0').Replace(' ', '0').Replace(':', '0');
             sqlStr2 = "insert into tbl_Finance values('" + financeID + "', " + totalPay + " , '出账' , '" +
                       CPublic.userInfo[0] + "', '" + generateDate + "')";
             CDataBase.UpdateDB(sqlStr2);
             btnPay.Enabled = false;
             RefreshStockData(publicSqlString1);
         }
     }
     catch (Exception ex)
     {
         CDataBase.conn.Close();
         MessageBox.Show(ex.Message);
     }
 }
Beispiel #25
0
 private void btnOK_Click(object sender, EventArgs e)
 {
     try
     {
         if (txtBookID.Text.Trim() == "")
         {
             MessageBox.Show("书籍编号不能为空!", "提示");
             txtBookID.Focus();
             return;
         }
         else if (txtISBN.Text.Trim() == "")
         {
             MessageBox.Show("ISBN不能为空!", "提示");
             txtISBN.Focus();
             return;
         }
         else if (txtTitle.Text.Trim() == "")
         {
             MessageBox.Show("书名不能为空!", "提示");
             txtTitle.Focus();
             return;
         }
         else if (txtAuthor.Text == "")
         {
             MessageBox.Show("作者不能为空!", "提示");
             txtAuthor.Focus();
             return;
         }
         else if (txtPublisher.Text.Trim() == "")
         {
             MessageBox.Show("出版社不能为空!", "提示");
             txtPublisher.Focus();
             return;
         }
         else if (txtYear.Text.Trim() == "")
         {
             MessageBox.Show("出版年份不能为空!", "提示");
             txtYear.Focus();
             return;
         }
         else if (txtImport.Text.Trim() == "")
         {
             MessageBox.Show("进货价不能为空!", "提示");
             txtImport.Focus();
             return;
         }
         else if (Convert.ToDouble(txtImport.Text.Trim()) < 0)
         {
             MessageBox.Show("进货价不能小于零", "提示");
             txtImport.Focus();
             return;
         }
         else if (txtImportNumber.Text.Trim() == "")
         {
             MessageBox.Show("进货数量不能为空!", "提示");
             txtImportNumber.Focus();
             return;
         }
         else if (Convert.ToInt32(txtImportNumber.Text.Trim()) < 0)
         {
             MessageBox.Show("进货数量不能小于零!", "提示");
             txtImportNumber.Focus();
             return;
         }
         else if (cmbWarehouse.Text.Trim() == "")
         {
             MessageBox.Show("进货仓库不能为空!", "提示");
             cmbWarehouse.Focus();
             return;
         }
         else if (txtRetail.Text.Trim() == "")
         {
             MessageBox.Show("零售价不能为空!", "提示");
             txtRetail.Focus();
             return;
         }
         else if (Convert.ToDouble(txtRetail.Text.Trim()) < 0)
         {
             MessageBox.Show("零售价不能小于零!", "提示");
             txtRetail.Focus();
             return;
         }
         else if (txtDiscount.Text.Trim() == "")
         {
             MessageBox.Show("折扣信息不能为空!", "提示");
             txtDiscount.Focus();
             return;
         }
         else if (Convert.ToDouble(txtDiscount.Text.Trim()) < 0 || Convert.ToDouble(txtDiscount.Text.Trim()) > 1)
         {
             MessageBox.Show("折扣信息不符合要求", "提示");
             txtDiscount.Focus();
             return;
         }
         else if (!No(txtBookID.Text.Trim()))
         {
             MessageBox.Show("该书已存在!", "提示");
             ClearAll();
             return;
         }
         double retail       = Convert.ToDouble(txtRetail.Text.Trim());
         double import       = Convert.ToDouble(txtImport.Text.Trim());
         int    importNumber = Convert.ToInt32(txtImportNumber.Text.Trim());
         double discount     = Convert.ToDouble(txtDiscount.Text.Trim());
         string sqlStr1      = "insert into tbl_Book values('" + txtBookID.Text.Trim() + "','"
                               + txtISBN.Text.Trim() + "','" + txtTitle.Text.Trim() + "','" + txtAuthor.Text.Trim() + "','"
                               + txtPublisher.Text.Trim() + "','" + txtYear.Text.Trim() + "','" + txtRetail.Text.Trim() + "','"
                               + txtImport.Text.Trim() + "', " + (retail - import) + " , " + (retail - import) / import + " , " + discount + " )";
         DateTime dt = System.DateTime.Now;
         string   generateDateTime = dt.ToString().Trim();
         string   sqlStr2          = "insert into tbl_ImportList values('" + cmbWarehouse.SelectedItem.ToString().Trim() + "','" +
                                     txtBookID.Text.Trim() + "', '" + generateDateTime + "' , " + import + " , " +
                                     importNumber + " , '未付款')";
         string sqlStr3 = "insert into tbl_Stocks values('" + cmbWarehouse.SelectedItem.ToString().Trim() + "','" +
                          txtBookID.Text.Trim() + "', 0 , 0 , 10)";
         if (CDataBase.UpdateDB(sqlStr1) && CDataBase.UpdateDB(sqlStr2) && CDataBase.UpdateDB(sqlStr3))
         {
             MessageBox.Show("添加新书成功!", "恭喜");
         }
         ClearAll();
     }
     catch (Exception ex)
     {
         CDataBase.conn.Close();
         MessageBox.Show(ex.Message);
         ClearAll();
     }
 }
Beispiel #26
0
 private void btnImport_Click(object sender, EventArgs e)
 {
     try
     {
         if (btnImport.Text == "进货")
         {
             btnImport.Text          = "确定";
             txtImportPrice.Enabled  = true;
             txtImportAmount.Enabled = true;
             return;
         }
         else
         {
             btnImport.Text          = "进货";
             txtImportPrice.Enabled  = false;
             txtImportAmount.Enabled = false;
             if (dgrdvStock.DataSource == null)
             {
                 MessageBox.Show("没有选择想要进货的书籍!", "提示");
                 return;
             }
             if (txtImportPrice.Text.Trim() == "")
             {
                 MessageBox.Show("请输入进货价!", "提示");
                 return;
             }
             else if (Convert.ToDouble(txtImportPrice.Text.Trim()) < 0)
             {
                 MessageBox.Show("进货价须大于零", "提示");
                 return;
             }
             else if (Convert.ToInt32(txtImportAmount.Text.Trim()) < 0)
             {
                 MessageBox.Show("进货数量须大于零", "提示");
                 return;
             }
             else if (txtImportAmount.Text.Trim() == "")
             {
                 MessageBox.Show("请输入进货数量!", "提示");
                 return;
             }
             int    n = dgrdvStock.CurrentCell.RowIndex;
             string warehouseID, bookID;
             warehouseID = dgrdvStock[0, n].Value.ToString().Trim();
             bookID      = dgrdvStock[2, n].Value.ToString().Trim();
             string sqlStr;
             sqlStr = "select * from tbl_ImportList where warehouseID='" + warehouseID +
                      "' and bookID='" + bookID + "'";
             if (CDataBase.GetDataFromDB(sqlStr) != null)
             {
                 if (MessageBox.Show("进货清单中已经存在该书的进货信息,仍然选择进货?",
                                     "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Warning,
                                     MessageBoxDefaultButton.Button2) == DialogResult.Yes)
                 {
                     ;
                 }
                 else
                 {
                     return;
                 }
             }
             DateTime generateDateTime = new DateTime();
             generateDateTime = System.DateTime.Now;
             sqlStr           = "insert into tbl_ImportList values('" + warehouseID + "','" + bookID + "','" +
                                generateDateTime.ToString().Trim() + "', " + Convert.ToDouble(txtImportPrice.Text.Trim()) + " , " +
                                Convert.ToInt32(txtImportAmount.Text.Trim()) + " , " + "'未付款')";
             CDataBase.UpdateDB(sqlStr);
             sqlStr = "delete from tbl_ImportList where status = '已付款' or status ='已退货'";
             CDataBase.UpdateDB(sqlStr);
             RefreshImportData();
             MessageBox.Show("添加进货清单成功!", "提示");
             btnPay.Enabled       = true;
             txtImportPrice.Text  = "";
             txtImportAmount.Text = "";
         }
     }
     catch (Exception ex)
     {
         CDataBase.conn.Close();
         MessageBox.Show(ex.Message);
     }
 }