private void Delete() { if (GuGuGuHelper.IsInDataGridView(selectRow, DGVCategories)) { string id = DGVCategories.Rows[selectRow].Cells["商品类别编号"].Value.ToString(); { string sql = "select * from Products where CategoryID = " + id + "'"; if (GuGuGuHelper.ExcuteExist(sql)) { MessageBox.Show("该类别下含有商品,禁止删除!"); return; } } { string sql = "delete from Categories where CategoryID = '" + id + "'"; int cnt = GuGuGuHelper.ExecuteNonQuery(sql); if (cnt >= 1) { MessageBox.Show("删除成功"); } else { MessageBox.Show("删除失败"); } CateRefresh(); } } else { MessageBox.Show("请选择正确的行"); } }
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(); } }
private void BtnAdd_Click(object sender, EventArgs e) { if (GuGuGuHelper.IsInDataGridView(selectRow, DGVProView)) { bool flag = true; DGVProViewFillTextBox(); DataRow row = NewRow(); for (int i = 0; i < DGVStock.RowCount - 1; i++) { if (DGVStock.Rows[i].Cells["商品号"].Value.ToString().Trim() == TbProID.Text.Trim()) { flag = false; DGVStock.Rows[i].Cells["数量"].Value = (Convert.ToInt32(DGVStock.Rows[i].Cells["数量"].Value) + Convert.ToInt32(TbQuantity.Text.Trim())).ToString(); } } if (flag) { table.Rows.Add(row); } DGVStock.DataSource = table; sum += Convert.ToDouble(TbUnitPrice.Text.Trim()) * Convert.ToDouble(TbDiscount.Text.Trim()) * Convert.ToDouble(TbQuantity.Text.Trim()); LbSum.Text = sum.ToString(); BtnDel.Enabled = true; } }
private void BtnDel_Click(object sender, EventArgs e) { if (DGVStock.CurrentCell != null) { selectRow = DGVStock.CurrentCell.RowIndex; } else { BtnDel.Enabled = false; } TextBoxEmpty(); if (GuGuGuHelper.IsInDataGridView(selectRow, DGVStock)) { DGVStockFillTextBox(); table.Rows.RemoveAt(selectRow); DGVStock.DataSource = table; sum -= Convert.ToDouble(TbUnitPrice.Text.Trim()) * Convert.ToDouble(TbDiscount.Text.Trim()) * Convert.ToDouble(TbQuantity.Text.Trim()); LbSum.Text = sum.ToString(); if (DGVStock.CurrentCell != null) { selectRow = DGVStock.CurrentCell.RowIndex; DGVStockFillTextBox(); } else { BtnDel.Enabled = false; } } //MessageBox.Show(selectRow.ToString()); }
private void DataProduct_CellClick(object sender, DataGridViewCellEventArgs e) { selectRow = e.RowIndex; if (GuGuGuHelper.IsInDataGridView(selectRow, DGVProduct) && op != "add") { TextBoxFill(); } }
private void BtnDelete_Click(object sender, EventArgs e) { TextBoxEmpty(); if (GuGuGuHelper.IsInDataGridView(selectRow, DGVProduct)) { TextBoxFill(); SetEnable(false, false, false, false, false, false, false, "当前操作模式:删除", true, "删除", true, "delete"); } }
private void DGVOrder_CellClick(object sender, DataGridViewCellEventArgs e) { selectRow = e.RowIndex; if (GuGuGuHelper.IsInDataGridView(selectRow, DGVOrder)) { LbTip.Text = "当前订单号:" + DGVOrder.Rows[selectRow].Cells["订单号"].Value.ToString(); OrderDetailsRefresh(); } }
private void DGVProView_CellClick(object sender, DataGridViewCellEventArgs e) { selectRow = e.RowIndex; TextBoxEmpty(); if (GuGuGuHelper.IsInDataGridView(selectRow, DGVProView)) { DGVProViewFillTextBox(); } }
private void CustomerMain_CellClick(object sender, DataGridViewCellEventArgs e) { selectRow = e.RowIndex; if (GuGuGuHelper.IsInDataGridView(selectRow, CustomerMain) && op != "add") { TextBoxEmpty(); TextBoxFill(); } }
private void DGVStock_CellDoubleClick(object sender, DataGridViewCellEventArgs e) { selectRow = e.RowIndex; if (GuGuGuHelper.IsInDataGridView(selectRow, DGVStock)) { TextBoxEmpty(); BtnDel.PerformClick(); } }
private void DGVProView_CellMouseDoubleClick(object sender, DataGridViewCellMouseEventArgs e) { selectRow = e.RowIndex; TextBoxEmpty(); if (GuGuGuHelper.IsInDataGridView(selectRow, DGVProView)) { DGVProViewFillTextBox(); BtnAdd.PerformClick(); } }
private void DGVCategories_CellClick(object sender, DataGridViewCellEventArgs e) { selectRow = e.RowIndex; if (GuGuGuHelper.IsInDataGridView(selectRow, DGVCategories)) { if (op == "delete" || op == "update") { TextBoxFill(); } } }
private void DGVInventory_CellClick(object sender, DataGridViewCellEventArgs e) { selectRow = e.RowIndex; if (GuGuGuHelper.IsInDataGridView(selectRow, DGVInventory)) { TextBoxFill(); } else { TextBoxEmpty(); } }
private void DGVInventory_CellPainting(object sender, DataGridViewCellPaintingEventArgs e) { for (int i = 0; GuGuGuHelper.IsInDataGridView(i, DGVInventory); ++i) { int quantity = Convert.ToInt32(DGVInventory.Rows[i].Cells["库存"].Value); int thrValue = Convert.ToInt32(DGVInventory.Rows[i].Cells["阈值"].Value); if (quantity < thrValue) { DGVInventory.Rows[i].DefaultCellStyle.ForeColor = Color.Red; } } }
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); }
private void BtnUpdCategories_Click(object sender, EventArgs e) { if (GuGuGuHelper.IsInDataGridView(selectRow, DGVCategories)) { TextBoxFill(); } TextBoxEmpty(); op = "update"; TbDe.Enabled = true; TbID.Enabled = false; TbName.Enabled = true; BtnOk.Enabled = true; LbTip.Text = "当前操作模式:更新"; BtnOk.Text = "更新"; }
private void BtnDelCategories_Click(object sender, EventArgs e) { if (GuGuGuHelper.IsInDataGridView(selectRow, DGVCategories)) { op = "delete"; TextBoxFill(); TbDe.Enabled = false; TbID.Enabled = false; TbName.Enabled = false; BtnOk.Enabled = true; BtnOk.Text = "确认删除"; LbTip.Text = "当前操作模式:删除"; } else { MessageBox.Show("请选择正确的行"); } }
private void Updates() { if (GuGuGuHelper.IsInDataGridView(selectRow, DGVProduct)) { string sql = "Update Products set ProductName = '" + TbProductName.Text.Trim() + "',SupplierID = '" + CbxCompanyName.SelectedValue + "',CategoryID = '" + CbxCategoryName.SelectedValue + "',UnitPrice = '" + TbUnitPrice.Text.Trim() + "', ThrValue = '" + TbValue.Text + "', Discont = '" + RbOK.Checked + "' where ProductID = '" + TbProductID.Text.Trim() + "'"; int cnt = GuGuGuHelper.ExecuteNonQuery(sql); if (cnt >= 1) { MessageBox.Show("修改成功"); } else { MessageBox.Show("修改失败"); } ProRefresh(); } else { MessageBox.Show("请选择正确的行"); } }
private void Delete() { if (GuGuGuHelper.IsInDataGridView(selectRow, CustomerMain)) { string id = CustomerMain.Rows[selectRow].Cells["客户编号"].Value.ToString(); string sql = "delete from Customers where CustomerID = '" + id + "'"; int cnt = GuGuGuHelper.ExecuteNonQuery(sql); if (cnt >= 1) { MessageBox.Show("删除成功"); } else { MessageBox.Show("删除失败,该用户存在订单或者其他未知错误"); } } else { MessageBox.Show("请选择正确的行"); } }
private void Updates() { if (GuGuGuHelper.IsInDataGridView(selectRow, DGVCategories)) { string id = DGVCategories.Rows[selectRow].Cells["商品类别编号"].Value.ToString(); string sql = "update Categories set CategoryName = '" + TbName.Text.Trim() + "',Description = '" + TbDe.Text.Trim() + "' where CategoryID = '" + id + "'"; int cnt = GuGuGuHelper.ExecuteNonQuery(sql); if (cnt >= 1) { MessageBox.Show("更新成功"); } else { MessageBox.Show("更新失败"); } CateRefresh(); } else { MessageBox.Show("请选择正确的行"); } }