Exemple #1
0
 private void Delete()
 {
     if (GuGuGuHelper.IsInDataGridView(selectRow, DGVProduct))
     {
         string checkSql = "select * from Inventory where ProductID = '" + TbProductID.Text + "'and quantity!=0";
         if (!GuGuGuHelper.ExcuteExist(checkSql))
         {
             List <string> sqlList = new List <string>();
             {
                 string sql = "delete from dbo.Inventory where ProductID = '" + TbProductID.Text + "'";
                 sqlList.Add(sql);
             }
             {
                 string sql = "delete from dbo.Products where ProductID = '" + TbProductID.Text + "'";
                 sqlList.Add(sql);
             }
             int cnt = GuGuGuHelper.ExecuteNonQueryTransaction(sqlList);
             if (cnt >= 2)
             {
                 MessageBox.Show("删除成功");
             }
             else
             {
                 MessageBox.Show("删除失败");
             }
         }
         else
         {
             MessageBox.Show("该商品已出售或者其他未知错误");
         }
         TextBoxFill();
     }
 }
Exemple #2
0
        private void Insert()
        {
            List <string> sqlList = new List <string>();
            {
                string sql = "Insert into Products values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}')";
                sql = string.Format(sql, TbProductID.Text, TbProductName.Text, CbxCompanyName.SelectedValue, CbxCategoryName.SelectedValue, TbUnitPrice.Text, TbProductName.Text, TbValue.Text.Trim(), RbOK.Checked);
                sqlList.Add(sql);
            }
            {
                string sql = "Insert into Inventory values('{0}','{1}','{2}')";
                sql = string.Format(sql, TbProductID.Text, "0", "千克/箱");
                sqlList.Add(sql);
            }
            int cnt = GuGuGuHelper.ExecuteNonQueryTransaction(sqlList);

            if (cnt == 2)
            {
                MessageBox.Show("添加成功");
            }
            else
            {
                MessageBox.Show("添加失败");
            }
            ProRefresh();
        }
Exemple #3
0
        private string GetRecepit()
        {
            List <string> trans      = new List <string>();
            string        orderID    = GuGuGuHelper.GetOrderID();
            string        customerID = GuGuGuHelper.ExecuteScalar("select CustomerID from Customers").ToString();
            string        sql        = "insert into Orders values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}')";

            sql = string.Format(sql, orderID, customerID, this.employeeID, GuGuGuHelper.GetNowTime(), 0, sum, "--", "--");
            trans.Add(sql);
            for (int i = 0; GuGuGuHelper.IsInDataGridView(i, DGVStock); ++i)
            {
                {
                    sql = string.Format("insert into \"Order Details\" values('{0}','{1}','{2}','{3}','{4}')",
                                        orderID,
                                        DGVStock.Rows[i].Cells["商品号"].Value.ToString(),
                                        DGVStock.Rows[i].Cells["单价"].Value.ToString(),
                                        DGVStock.Rows[i].Cells["数量"].Value.ToString(),
                                        DGVStock.Rows[i].Cells["折扣"].Value.ToString());
                    trans.Add(sql);
                }
                {
                    sql = string.Format("update Inventory set Quantity = Quantity - '{0}' where ProductID = '{1}'",
                                        DGVStock.Rows[i].Cells["数量"].Value.ToString(),
                                        DGVStock.Rows[i].Cells["商品号"].Value.ToString());
                    trans.Add(sql);
                }
            }
            int cnt = GuGuGuHelper.ExecuteNonQueryTransaction(trans);

            if (cnt > 0)
            {
                MessageBox.Show("支付成功!正在打印凭条!");
            }
            else
            {
                MessageBox.Show("出现错误!");
            }
            DataRow rowPay = table.NewRow();

            rowPay["商品名"] = "总金额";
            rowPay["单价"]  = LbSum.Text.Trim();
            table.Rows.Add(rowPay);
            DataRow row = table.NewRow();

            row["商品名"] = "单号";
            row["单价"]  = orderID;
            table.Rows.Add(row);
            DGVStock.DataSource = table;
            LbSum.Text          = "0";
            return(orderID);
        }
Exemple #4
0
        private void BtnFinish_Click(object sender, EventArgs e)
        {
            List <string> list = new List <string>();

            for (int i = 0; i < DGVDataStock.Rows.Count - 1; i++)
            {
                string sql = "Update Inventory set Quantity = '" + DGVDataStock.Rows[i].Cells["商品数量"].Value.ToString() + "'" + "+Quantity where productID = '" + DGVDataStock.Rows[i].Cells["商品编号"].Value.ToString() + "'";
                list.Add(sql);
            }
            int d = GuGuGuHelper.ExecuteNonQueryTransaction(list);

            if (d == DGVDataStock.Rows.Count - 1)
            {
                MessageBox.Show("数据写入成功");
                StockReFresh();
            }
            else
            {
                MessageBox.Show("数据写入失败");
            }
        }