private void LoadView() { ActiveUser.Text = "当前工号:[" + activeUser + "]"; string sql = "select Name from Employees where EmployeeID = '" + activeUser + "'"; activeUserName = GuGuGuHelper.ExecuteScalar(sql).ToString(); ActiveUserName.Text = "姓名:" + activeUserName; string tip = "您好!"; int hh = Convert.ToInt32(DateTime.Now.ToString("HH")); if (hh >= 6 && hh <= 8) { tip = "早上好!"; } else if (hh >= 9 && hh < 12) { tip = "上午好!"; } else if (hh >= 12 && hh < 14) { tip = "中午好!"; } else if (hh >= 14 && hh < 19) { tip = "下午好!"; } else if (hh >= 19 && hh < 24) { tip = "晚上好!"; } LogoTip.Text = activeUserName + "," + tip; }
/// <summary> /// 商品编号自动生成 /// </summary> /// <returns>返回自动生成的商品编号</returns> public static string GetProductID() { string sql = "select ProductID from Products order by ProductID desc"; string rear = (Convert.ToInt32(GuGuGuHelper.ExecuteScalar(sql).ToString().Substring(1, 6)) + 1).ToString("000000"); string head = "P"; return(head + rear); }
/// <summary> /// 顾客编号自动生成 /// </summary> /// <returns>返回生成的顾客编号</returns> public static string GetCustomerID() { string sql = "select CustomerID from Customers order by CustomerID desc"; string head = "CUS"; string rear = (Convert.ToInt32(GuGuGuHelper.ExecuteScalar(sql).ToString().Substring(3, 6)) + 1).ToString("000000"); return(head + rear); }
/// <summary> /// 自动生成类别号 /// </summary> /// <returns>返回类别号</returns> public static string GetCategoryID() { string sql = "select CategoryID from Categories order by CategoryID desc"; string rear = (Convert.ToInt32(GuGuGuHelper.ExecuteScalar(sql).ToString().Substring(4, 6)) + 1).ToString("000000"); string head = "CATE"; return(head + rear); }
/// <summary> /// 自动生成订单号 /// </summary> /// <returns>返回订单号</returns> public static string GetOrderID() { string sql = "select OrderID from Orders order by OrderDate desc"; string rear = ((Convert.ToInt32(GuGuGuHelper.ExecuteScalar(sql).ToString().Substring(8, 4)) + 10) % 10000).ToString("0000"); string head = DateTime.Now.ToString("yyyyMMdd"); return(head + rear); }
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); }