예제 #1
0
        public void RefreshData()
        {
            string  sqlStr = "";
            DataSet ds     = new DataSet();

            if (cmbUserType.Text.Trim() == "普通管理员")
            {
                sqlStr = "select " + dgrdvAdminSelectSql +
                         " from tbl_Admin where adminType= '普通管理员'";
                ds = CDataBase.GetDataFromDB(sqlStr);
                if (ds != null)
                {
                    SetDgrdvAdmin(ds);
                }
                else
                {
                    dgrdvUser.DataSource = null;
                }
            }
            else
            {
                sqlStr = "select * from tbl_Customer";
                ds     = CDataBase.GetDataFromDB(sqlStr);
                if (ds != null)
                {
                    SetDgrdvCustomer(ds);
                }
                else
                {
                    dgrdvUser.DataSource = null;
                }
            }
        }
예제 #2
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);
     }
 }
예제 #3
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);
     }
 }
예제 #4
0
        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();
            }
        }
예제 #5
0
        bool RefreshBookData(string sqlStr)
        {
            DataSet ds = new DataSet();

            ds = CDataBase.GetDataFromDB(sqlStr);
            if (ds != null)
            {
                dgrdvBookCity.DataSource            = ds.Tables[0];
                dgrdvBookCity.Columns[0].HeaderText = "仓库编号";
                dgrdvBookCity.Columns[0].Width      = 100;
                dgrdvBookCity.Columns[1].HeaderText = "书籍编号";
                dgrdvBookCity.Columns[1].Width      = 98;
                dgrdvBookCity.Columns[2].HeaderText = "书名";
                dgrdvBookCity.Columns[2].Width      = 98;
                dgrdvBookCity.Columns[3].HeaderText = "作者";
                dgrdvBookCity.Columns[3].Width      = 80;
                dgrdvBookCity.Columns[4].HeaderText = "出版社";
                dgrdvBookCity.Columns[4].Width      = 80;
                dgrdvBookCity.Columns[5].HeaderText = "零售价";
                dgrdvBookCity.Columns[5].Width      = 80;
                dgrdvBookCity.Columns[6].HeaderText = "折扣信息";
                dgrdvBookCity.Columns[6].Width      = 80;
                return(true);
            }
            else
            {
                dgrdvBookCity.DataSource = null;
                return(false);
            }
        }
예제 #6
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);
     }
 }
예제 #7
0
        bool RefreshFinanceData(string sqlStr)
        {
            DataSet ds = new DataSet();

            ds = CDataBase.GetDataFromDB(sqlStr);
            if (ds != null)
            {
                dgrdvFinance.DataSource            = ds.Tables[0];
                dgrdvFinance.Columns[0].HeaderText = "账单编号";
                dgrdvFinance.Columns[0].Width      = 137;
                dgrdvFinance.Columns[1].HeaderText = "金额";
                dgrdvFinance.Columns[1].Width      = 70;
                dgrdvFinance.Columns[2].HeaderText = "类型";
                dgrdvFinance.Columns[2].Width      = 60;
                dgrdvFinance.Columns[3].HeaderText = "创建者";
                dgrdvFinance.Columns[3].Width      = 112;
                dgrdvFinance.Columns[4].HeaderText = "创建时间";
                dgrdvFinance.Columns[4].Width      = 120;
                return(true);
            }
            else
            {
                dgrdvFinance.DataSource = null;
                return(false);
            }
        }
예제 #8
0
        void RefreshImportData()
        {
            string  sqlStr1;
            DataSet ds1 = new DataSet();

            sqlStr1 = "select tbl_ImportList.warehouseID, tbl_Warehouse.warehouseCity, tbl_Book.bookID," +
                      " tbl_Book.title, tbl_ImportList.importPrice, tbl_ImportList.importNumber, tbl_ImportList.status, tbl_ImportList.generateDateTime " +
                      " from tbl_ImportList , tbl_Book, tbl_Warehouse where tbl_ImportList.bookID = tbl_Book.bookID " +
                      "and tbl_ImportList.warehouseID = tbl_Warehouse.warehouseID ";
            ds1 = CDataBase.GetDataFromDB(sqlStr1);
            if (ds1 != null)
            {
                dgrdvImportList.DataSource            = ds1.Tables[0];
                dgrdvImportList.Columns[0].HeaderText = "仓库编号";
                dgrdvImportList.Columns[0].Width      = 80;
                dgrdvImportList.Columns[1].HeaderText = "仓库所在地";
                dgrdvImportList.Columns[1].Width      = 95;
                dgrdvImportList.Columns[2].HeaderText = "书籍编号";
                dgrdvImportList.Columns[2].Width      = 80;
                dgrdvImportList.Columns[3].HeaderText = "书名";
                dgrdvImportList.Columns[3].Width      = 78;
                dgrdvImportList.Columns[4].HeaderText = "进货价";
                dgrdvImportList.Columns[4].Width      = 75;
                dgrdvImportList.Columns[5].HeaderText = "进货数量";
                dgrdvImportList.Columns[5].Width      = 80;
                dgrdvImportList.Columns[6].HeaderText = "当前状态";
                dgrdvImportList.Columns[6].Width      = 80;
                dgrdvImportList.Columns[7].HeaderText = "生成日期";
                dgrdvImportList.Columns[7].Width      = 135;
            }
            else
            {
                dgrdvImportList.DataSource = null;
            }
        }
예제 #9
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();
     }
 }
예제 #10
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);
     }
 }
예제 #11
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);
     }
 }
예제 #12
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();
     }
 }
예제 #14
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);
     }
 }
예제 #15
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);
     }
 }
예제 #16
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();
     }
 }
예제 #17
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);
     }
 }
예제 #18
0
        bool No(string no)
        {
            string  sqlStr = "select * from tbl_Book";
            DataSet ds     = new DataSet();

            ds = CDataBase.GetDataFromDB(sqlStr);
            if (ds != null)
            {
                int n = ds.Tables[0].Rows.Count;
                for (int i = 0; i < n; i++)
                {
                    if (no == ds.Tables[0].Rows[i].ItemArray[0].ToString().Trim())
                    {
                        return(false);
                    }
                }
            }
            return(true);
        }
예제 #19
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);
     }
 }
예제 #20
0
        bool RefreshData(string sqlStr)
        {
            DataSet ds = new DataSet();

            ds = CDataBase.GetDataFromDB(sqlStr);
            if (ds != null)
            {
                dgrdvBook.DataSource             = ds.Tables[0];
                dgrdvBook.Columns[0].HeaderText  = "书籍编号";
                dgrdvBook.Columns[0].Width       = 80;
                dgrdvBook.Columns[1].HeaderText  = "ISBN";
                dgrdvBook.Columns[1].Width       = 80;
                dgrdvBook.Columns[2].HeaderText  = "书名";
                dgrdvBook.Columns[2].Width       = 115;
                dgrdvBook.Columns[3].HeaderText  = "作者";
                dgrdvBook.Columns[3].Width       = 60;
                dgrdvBook.Columns[4].HeaderText  = "出版社";
                dgrdvBook.Columns[4].Width       = 70;
                dgrdvBook.Columns[5].HeaderText  = "出版年份";
                dgrdvBook.Columns[5].Width       = 80;
                dgrdvBook.Columns[6].HeaderText  = "零售价";
                dgrdvBook.Columns[6].Width       = 70;
                dgrdvBook.Columns[7].HeaderText  = "进货价";
                dgrdvBook.Columns[7].Width       = 70;
                dgrdvBook.Columns[8].HeaderText  = "利润";
                dgrdvBook.Columns[8].Width       = 40;
                dgrdvBook.Columns[9].HeaderText  = "利润率";
                dgrdvBook.Columns[9].Width       = 70;
                dgrdvBook.Columns[10].HeaderText = "折扣信息";
                dgrdvBook.Columns[10].Width      = 80;
                dgrdvBook_RowHeaderMouseClick(null, null);
                return(true);
            }
            else
            {
                dgrdvBook.DataSource = null;
                return(false);
            }
        }
예제 #21
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();
     }
 }
예제 #22
0
        private void FrmAddNewBook_Load(object sender, EventArgs e)
        {
            string  sqlStr = "select * from tbl_Warehouse";
            DataSet ds     = new DataSet();

            ds = CDataBase.GetDataFromDB(sqlStr);
            if (ds != null)
            {
                int n = ds.Tables[0].Rows.Count;
                cmbWarehouse.Items.Clear();
                for (int i = 0; i < n; i++)
                {
                    cmbWarehouse.Items.Add(ds.Tables[0].Rows[i].ItemArray[0]);
                }
                cmbWarehouse.SelectedIndex = -1;
            }
            else
            {
                MessageBox.Show("没有可用的仓库", "警告");
                this.Close();
            }
        }
예제 #23
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);
     }
 }
예제 #24
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();
     }
 }
예제 #25
0
        bool RefreshData(string sqlStr)
        {
            DataSet ds = new DataSet();

            ds = CDataBase.GetDataFromDB(sqlStr);
            if (ds != null)
            {
                dgrdvOrder.DataSource            = ds.Tables[0];
                dgrdvOrder.Columns[0].HeaderText = "书名";
                dgrdvOrder.Columns[0].Width      = 100;
                dgrdvOrder.Columns[1].HeaderText = "数量";
                dgrdvOrder.Columns[1].Width      = 60;
                dgrdvOrder.Columns[2].HeaderText = "付款时间";
                dgrdvOrder.Columns[2].Width      = 115;
                dgrdvOrder.Columns[3].HeaderText = "订单状态";
                dgrdvOrder.Columns[3].Width      = 100;
                return(true);
            }
            else
            {
                dgrdvOrder.DataSource = null;
                return(false);
            }
        }
예제 #26
0
        void RefreshBasketData()
        {
            string sqlStr = "select  tbl_Stocks.warehouseID, tbl_Book.bookID, tbl_Book.title, tbl_Book.retailPrice, tbl_ShoppingBasket.basketNumber, " +
                            " tbl_Book.discountRate, tbl_Stocks.leftAmount, tbl_ShoppingBasket.basketStatus " +
                            " from tbl_Book, tbl_ShoppingBasket, tbl_Stocks where tbl_Book.bookID = tbl_ShoppingBasket.bookID and " +
                            " tbl_Stocks.warehouseID = tbl_ShoppingBasket.warehouseID and " +
                            " tbl_Stocks.bookID = tbl_Book.bookID and tbl_ShoppingBasket.customerEmail = '" +
                            CPublic.userInfo[0] + "'";
            DataSet ds = new DataSet();

            ds = CDataBase.GetDataFromDB(sqlStr);
            if (ds != null)
            {
                dgrdvBasket.DataSource            = ds.Tables[0];
                dgrdvBasket.Columns[0].HeaderText = "仓库编号";
                dgrdvBasket.Columns[0].Width      = 100;
                dgrdvBasket.Columns[1].HeaderText = "书籍编号";
                dgrdvBasket.Columns[1].Width      = 100;
                dgrdvBasket.Columns[2].HeaderText = "书名";
                dgrdvBasket.Columns[2].Width      = 80;
                dgrdvBasket.Columns[3].HeaderText = "单价";
                dgrdvBasket.Columns[3].Width      = 60;
                dgrdvBasket.Columns[4].HeaderText = "数量";
                dgrdvBasket.Columns[4].Width      = 60;
                dgrdvBasket.Columns[5].HeaderText = "折扣信息";
                dgrdvBasket.Columns[5].Width      = 80;
                dgrdvBasket.Columns[6].HeaderText = "库存量";
                dgrdvBasket.Columns[6].Width      = 80;
                dgrdvBasket.Columns[7].HeaderText = "状态";
                dgrdvBasket.Columns[7].Width      = 60;
            }
            else
            {
                dgrdvBasket.DataSource = null;
            }
        }
예제 #27
0
        bool RefreshData(string sqlStr)
        {
            DataSet ds = new DataSet();

            ds = CDataBase.GetDataFromDB(sqlStr);
            if (ds != null)
            {
                dgrdvWarehouse.DataSource            = ds.Tables[0];
                dgrdvWarehouse.Columns[0].HeaderText = "仓库编号";
                dgrdvWarehouse.Columns[0].Width      = 82;
                dgrdvWarehouse.Columns[1].HeaderText = "所在城市";
                dgrdvWarehouse.Columns[1].Width      = 80;
                dgrdvWarehouse.Columns[2].HeaderText = "联系电话";
                dgrdvWarehouse.Columns[2].Width      = 100;
                dgrdvWarehouse.Columns[3].HeaderText = "每月租金";
                dgrdvWarehouse.Columns[3].Width      = 80;
                return(true);
            }
            else
            {
                dgrdvWarehouse.DataSource = null;
                return(false);
            }
        }
예제 #28
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);
     }
 }
예제 #29
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();
     }
 }
예제 #30
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);
     }
 }