示例#1
0
		public static void Print(string billDetailID)
		{
			if (billDetailID != null)
			{
				GetConfig();
				SqlConnection connection = ConnectDB.GetConnection();
				SqlCommand selectCommand = new SqlCommand("getBillDetailList", connection);
				selectCommand.CommandType = CommandType.StoredProcedure;
				selectCommand.Parameters.Add("@billDetailIDList", SqlDbType.NVarChar).Value = billDetailID;
				SqlDataAdapter adapter = new SqlDataAdapter(selectCommand);
				DataTable dataTable = new DataTable();
				adapter.Fill(dataTable);
				connection.Close();
				if (dataTable.Rows.Count != 0)
				{
					PrintSlip slip = new PrintSlip("KIT",0);
					StringBuilder builder = new StringBuilder();
					int num = -1;
					int num2 = -1;
					string str = "0";
					int num3 = 0;
					for (int i = 0; i < dataTable.Rows.Count; i++)
					{
						string str2 = dataTable.Rows[i]["printline"].ToString();
						int num5 = (int) dataTable.Rows[i]["menutype"];
						int num6 = (int) dataTable.Rows[i]["tableid"];
						string str3 = dataTable.Rows[i]["tablename"].ToString();
						string str4 = dataTable.Rows[i]["menukeyid"].ToString();
						string str5 = dataTable.Rows[i]["menushortname"].ToString();
						int num7 = (int) dataTable.Rows[i]["unit"];
						string str6 = dataTable.Rows[i]["message"].ToString();
						string str7 = dataTable.Rows[i]["choicename"].ToString();
						string str8 = dataTable.Rows[i]["custfirstname"].ToString();
						string str9 = dataTable.Rows[i]["custmiddlename"].ToString();
						string str10 = dataTable.Rows[i]["custlastname"].ToString();
						short num8 = (short) dataTable.Rows[i]["status"];
						if (num != num6)
						{
							slip.Add("", 0, 1);
							slip.Add("", 0, 1);
							slip.Add("", 0, 1);
							slip.Add("", 0, 1);
							if (num6 == 0)
							{
								if (showTakeOutBar)
								{
									slip.Add("-XXX-", 0, 1);
								}
								else
								{
									slip.Add("", 0, 1);
								}
								builder.Length = 0;
								builder.Append(str3);
								slip.Add(builder.ToString(), 0, 1);
								if (showCustName)
								{
									builder.Length = 0;
									if (str8.Length > 0)
									{
										builder.Append(str8);
									}
									if (str9.Length > 0)
									{
										builder.Append(" ");
										builder.Append(str9);
									}
									if (str10.Length > 0)
									{
										builder.Append(" ");
										builder.Append(str10);
									}
									slip.Add(builder.ToString(), 0, 1);
								}
							}
							else
							{
								slip.Add("", 0, 1);
								builder.Length = 0;
								builder.Append("Table:");
								builder.Append(str3);
								slip.Add(builder.ToString(), 0, 1);
							}
							builder.Length = 0;
							if (showTime)
							{
								builder.Append(DateTime.Now.ToString("HH:mm"));
							}
							if (showDate)
							{
								if (builder.Length == 0)
								{
									builder.Append(DateTime.Now.ToString("yyyy/MM/dd"));
								}
								else
								{
									builder.Append(DateTime.Now.ToString("     yyyy/MM/dd"));
								}
							}
							if (builder.Length > 0)
							{
								slip.Add(builder.ToString(), 0, 1);
							}
							num = num6;
							num3 = 0;
						}
						if ((num2 != num5) && (str == "1"))
						{
							slip.Add("-", 1, 0);
						}
						num2 = num5;
						str = str2;
						builder.Length = 0;
						builder.Append(str4);
						if (num7 != 1)
						{
							builder.Append(" (");
							builder.Append(num7);
							builder.Append(")");
						}
						else
						{
							builder.Append(" ");
						}
						if (showShortName)
						{
							builder.Append(str5);
							if (num8 == 0)
							{
								builder.Append(" (Cancel)");
							}
							else if (num8 < 0)
							{
								builder.Append(" (Change)");
							}
							slip.Add(builder.ToString(), 1, 0);
							if (str7 != "")
							{
								string[] strArray = str7.Split(new char[] { ',' });
								for (int j = 0; j < strArray.Length; j++)
								{
									builder.Length = 0;
									builder.Append("  - ");
									builder.Append(strArray[j]);
									slip.Add(builder.ToString(), 2, 0);
								}
							}
						}
						else
						{
							if (num8 == 0)
							{
								builder.Append("(Can) ");
							}
							else if (num8 < 0)
							{
								builder.Append("(Chg) ");
							}
							if (str7 != "")
							{
								builder.Append(str7);
							}
							slip.Add(builder.ToString(), 1, 0);
						}
						if (str6 != "")
						{
							builder.Length = 0;
							builder.Append("  - ");
							builder.Append(str6);
							slip.Add(builder.ToString(), 3, 0);
						}
						num3 += num7;
					}
					if ((num == 0) && showTotal)
					{
						connection = ConnectDB.GetConnection();
						selectCommand = new SqlCommand("getOrderBillComputePriceByBillDetailID", connection);
						selectCommand.CommandType = CommandType.StoredProcedure;
						selectCommand.Parameters.Add("@billDetailID", SqlDbType.Int).Value = billDetailID.Split(new char[] { ',' })[0];
						adapter = new SqlDataAdapter(selectCommand);
						dataTable = new DataTable();
						adapter.Fill(dataTable);
						connection.Close();
						if (dataTable.Rows.Count > 0)
						{
							double num10 = double.Parse(dataTable.Rows[0]["totalprice"].ToString());
							double num11 = double.Parse(dataTable.Rows[0]["totaltax1"].ToString());
							double num12 = double.Parse(dataTable.Rows[0]["totaltax2"].ToString());
							num10 += num11 + num12;
							builder.Length = 0;
							builder.Append("Total: ");
							builder.Append(num10.ToString("f"));
							slip.Add(builder.ToString(), 1, 0);
						}
					}
					slip.Print();
				}
			}
		}
		public static void Print(DateTime date, int empType)
		{
			SqlConnection connection = ConnectDB.GetConnection();
			SqlCommand selectCommand = new SqlCommand("getRptInvoiceByDate", connection);
			selectCommand.CommandType = CommandType.StoredProcedure;
			selectCommand.Parameters.Add("@date", SqlDbType.DateTime).Value = date;
			selectCommand.Parameters.Add("@empType", SqlDbType.Int).Value = empType;
			SqlDataAdapter adapter = new SqlDataAdapter(selectCommand);
			DataTable dataTable = new DataTable();
			adapter.Fill(dataTable);
			if (dataTable.Rows.Count == 0)
			{
				connection.Close();
			}
			else
			{
				connection.Close();
				PrintSlip slip = new PrintSlip("BIL",0);
				StringBuilder builder = new StringBuilder();
				int num = 0;
				int num2 = 1;
				for (int i = 0; i < dataTable.Rows.Count; i++)
				{
					int num4 = (int) dataTable.Rows[i]["invoiceid"];
					string str2 = dataTable.Rows[i]["Date"].ToString();
					string str3 = dataTable.Rows[i]["Time"].ToString();
					string str4 = dataTable.Rows[i]["Paid By"].ToString();
					double num5 = double.Parse(dataTable.Rows[i]["Total"].ToString());
					bool flag = (bool) dataTable.Rows[i]["hidden"];
					if (i == 0)
					{
						builder.Length = 0;
						builder.Append("Date: ");
						builder.Append(str2);
						slip.Add(builder.ToString(), 0, 1);
						slip.Add("", 1, 0);
					}
					builder.Length = 0;
					if (num != num4)
					{
						builder.Append(num2);
						if (builder.Length < 5)
						{
							builder.Append(new string(' ', 5 - builder.Length));
						}
						num2++;
					}
					else
					{
						builder.Append(new string(' ', 5));
					}
					if (flag)
					{
						builder.Append('*');
					}
					else
					{
						builder.Append(' ');
					}
					builder.Append(str3);
					builder.Append(' ');
					if (str4.Length > 10)
					{
						builder.Append(str4.Substring(0, 10));
					}
					else
					{
						builder.Append(str4);
						if (str4.Length < 10)
						{
							builder.Append(new string(' ', 10 - str4.Length));
						}
					}
					string str = num5.ToString("f");
					if (str.Length < 9)
					{
						builder.Append(new string(' ', 9 - str.Length));
					}
					builder.Append(str);
					slip.Add(builder.ToString(), 1, 0);
					num = num4;
				}
				slip.Print();
			}
		}
		public static void Print(int orderBillID)
		{
			if (orderBillID != 0)
			{
				GetConfig();
				SqlConnection connection = ConnectDB.GetConnection();
				SqlCommand selectCommand = new SqlCommand("getOrderBillReceipt", connection);
				selectCommand.CommandType = CommandType.StoredProcedure;
				selectCommand.Parameters.Add("@orderBillID", SqlDbType.Int).Value = orderBillID;
				SqlDataAdapter adapter = new SqlDataAdapter(selectCommand);
				DataTable dataTable = new DataTable();
				adapter.Fill(dataTable);
				if (dataTable.Rows.Count == 0)
				{
					connection.Close();
				}
				else
				{
					selectCommand.CommandText = "getOrderBillSummary";
					adapter = new SqlDataAdapter(selectCommand);
					DataTable table2 = new DataTable();
					adapter.Fill(table2);
					if (table2.Rows.Count == 0)
					{
						connection.Close();
					}
					else
					{
						double totalPrice;
						double num4;
						double num5;
						double num6;
						string str11;
						connection.Close();
						int num = (int) table2.Rows[0]["TableID"];
						string str = (string) table2.Rows[0]["TableName"];
						int num2 = (int) table2.Rows[0]["BillID"];
						string str2 = (string) table2.Rows[0]["EmpName"];
						string str3 = (string) table2.Rows[0]["CustName"];
						string text = (string) table2.Rows[0]["CustAddress"];
						string str5 = (string) table2.Rows[0]["CustTel"];
						string str6 = (string) table2.Rows[0]["CustDescription"];
						string str7 = (string) table2.Rows[0]["CustRoad"];
						string str8 = (string) table2.Rows[0]["CustArea"];
						DateTime time = (table2.Rows[0]["InvoiceTime"] is DBNull) ? DateTime.MinValue : ((DateTime) table2.Rows[0]["InvoiceTime"]);
						try
						{
							num6 = double.Parse(table2.Rows[0]["TotalDiscount"].ToString());
							double.Parse(table2.Rows[0]["TotalReceive"].ToString());
						}
						catch (Exception)
						{
							totalPrice = 0.0;
							num4 = num5 = 0.0;
							num6 = 0.0;
						}
						BillPrice price = CheckBillService.ComputeBillPrice(orderBillID);
						totalPrice = price.totalPrice;
						num4 = price.totalTax1;
						num5 = price.totalTax2;
						string descriptionByID = CheckBillService.GetDescriptionByID("TAX1");
						string str10 = CheckBillService.GetDescriptionByID("TAX2");
						if (descriptionByID == null)
						{
							descriptionByID = "Tax1";
						}
						if (str10 == null)
						{
							str10 = "Tax2";
						}
						PrintSlip slip = new PrintSlip("RCP");
						StringBuilder builder = new StringBuilder();
						for (int i = 0; i < dataTable.Rows.Count; i++)
						{
							string str14;
							int num1 = (int) dataTable.Rows[i]["MenuID"];
							string str12 = dataTable.Rows[i]["MenuKeyID"].ToString();
							string str13 = (string) dataTable.Rows[i]["MenuShortName"];
							int num8 = (int) dataTable.Rows[i]["Unit"];
							double num9 = double.Parse(dataTable.Rows[i]["Price"].ToString());
							double num10 = double.Parse(dataTable.Rows[i]["NetPrice"].ToString());
							double.Parse(dataTable.Rows[i]["Tax1"].ToString());
							double.Parse(dataTable.Rows[i]["Tax2"].ToString());
							int num11 = (int) dataTable.Rows[i]["Status"];
							if (i == 0)
							{
								if (str3 != string.Empty)
								{
									builder.Length = 0;
									builder.Append("Cust: ");
									builder.Append(str3);
									slip.Add(builder.ToString(), 0, 1);
									if (text != string.Empty)
									{
										slip.Add(text, 0, 1);
									}
									if (str5 != string.Empty)
									{
										builder.Length = 0;
										builder.Append("Tel: ");
										builder.Append(str5);
										slip.Add(builder.ToString(), 0, 1);
									}
									if (str7 != string.Empty)
									{
										builder.Length = 0;
										builder.Append(str7);
										if (str8 != string.Empty)
										{
											builder.Append(" (");
											builder.Append(str8);
											builder.Append(")");
										}
										slip.Add(builder.ToString(), 0, 1);
									}
									if (str6 != string.Empty)
									{
										slip.Add(str6, 1, 1);
									}
									slip.Add("", 1, 0);
								}
								slip.AddHeader();
								builder.Length = 0;
								if (num != 0)
								{
									builder.Append("Table: ");
									builder.Append(str);
									builder.Append("-");
									builder.Append(num2);
								}
								else
								{
									builder.Append(str);
								}
								slip.Add(builder.ToString(), 0, 1);
								builder.Length = 0;
								if (time.CompareTo(DateTime.MinValue) > 0)
								{
									builder.Append(time.ToString("HH:mm     yyyy/MM/dd"));
								}
								else
								{
									builder.Append(DateTime.Now.ToString("HH:mm     yyyy/MM/dd"));
								}
								slip.Add(builder.ToString(), 0, 1);
								builder.Length = 0;
								builder.Append("Emp: " + str2);
								slip.Add(builder.ToString(), 1, 1);
								slip.Add("", 1, 0);
							}
							builder.Length = 0;
							if (showMenuKeyID)
							{
								builder.Append(str12);
								builder.Append(".");
								str14 = " ";
							}
							else
							{
								str14 = "    ";
							}
							builder.Append(str13);
							if (builder.Length < 13)
							{
								builder.Append(new string(' ', 13 - builder.Length));
							}
							if (builder.Length > 13)
							{
								builder.Length = 13;
							}
							builder.Append(str14);
							if (num8 < 10)
							{
								builder.Append("  ");
							}
							else if (num8 < 100)
							{
								builder.Append(" ");
							}
							builder.Append(num8.ToString());
							builder.Append(" ");
							if (num11 > 0)
							{
								str11 = num9.ToString("f");
								if (str11.Length < 6)
								{
									builder.Append(new string(' ', 6 - str11.Length));
								}
								builder.Append(str11);
								builder.Append(" ");
								str11 = num10.ToString("f");
								if (str11.Length < 6)
								{
									builder.Append(new string(' ', 6 - str11.Length));
								}
								builder.Append(str11);
							}
							else
							{
								builder.Append("         N/C ");
							}
							slip.Add(builder.ToString(), 1, 0);
						}
						builder.Length = 0;
						builder.Append("Sub Total               ");
						str11 = totalPrice.ToString("f");
						if (str11.Length < 7)
						{
							builder.Append(new string(' ', 7 - str11.Length));
						}
						builder.Append(str11);
						slip.Add(builder.ToString(), 2, 0);
						if ((str10 != "") || (num5 > 0.0))
						{
							builder.Length = 0;
							builder.Append(str10);
							if (str10.Length < 20)
							{
								builder.Append(new string(' ', 20 - str10.Length));
							}
							builder.Append("    ");
							str11 = num5.ToString("f");
							if (str11.Length < 7)
							{
								builder.Append(new string(' ', 7 - str11.Length));
							}
							builder.Append(str11);
							slip.Add(builder.ToString(), 2, 0);
						}
						if ((descriptionByID != "") || (num4 > 0.0))
						{
							builder.Length = 0;
							builder.Append(descriptionByID);
							if (descriptionByID.Length < 20)
							{
								builder.Append(new string(' ', 20 - descriptionByID.Length));
							}
							builder.Append("    ");
							str11 = num4.ToString("f");
							if (str11.Length < 7)
							{
								builder.Append(new string(' ', 7 - str11.Length));
							}
							builder.Append(str11);
							slip.Add(builder.ToString(), 2, 0);
						}
						if (num6 > 0.0)
						{
							builder.Length = 0;
							builder.Append("Discount                ");
							str11 = num6.ToString("f");
							if (str11.Length < 7)
							{
								builder.Append(new string(' ', 7 - str11.Length));
							}
							builder.Append(str11);
							slip.Add(builder.ToString(), 2, 0);
						}
						builder.Length = 0;
						builder.Append("Total                   ");
						str11 = (((totalPrice + num4) + num5) - num6).ToString("f");
						if (str11.Length < 7)
						{
							builder.Append(new string(' ', 7 - str11.Length));
						}
						builder.Append(str11);
						slip.Add(builder.ToString(), 3, 0);
						if (!AppParameter.IsDemo() && showGratuity)
						{
							builder.Length = 0;
							builder.Append("Gratuity                _______");
							slip.Add(builder.ToString(), 3, 0);
							builder.Length = 0;
							builder.Append("Grand Total             _______");
							slip.Add(builder.ToString(), 3, 0);
						}
						slip.AddFooter();
						slip.Print();
					}
				}
			}
		}
示例#4
0
		private static void Print(int type, DateTime date)
		{
			SqlConnection connection = ConnectDB.GetConnection();
			SqlCommand selectCommand = new SqlCommand();
			switch (type)
			{
				case 1:
					selectCommand.CommandText = "getSummaryMenuType";
					break;

				case 2:
					selectCommand.CommandText = "getSummaryReceive";
					break;

				default:
					return;
			}
			selectCommand.Connection = connection;
			selectCommand.CommandType = CommandType.StoredProcedure;
			selectCommand.Parameters.Add("@date", SqlDbType.DateTime).Value = date;
			SqlDataAdapter adapter = new SqlDataAdapter(selectCommand);
			DataTable dataTable = new DataTable();
			adapter.Fill(dataTable);
			connection.Close();
			if (dataTable.Rows.Count != 0)
			{
				PrintSlip slip = new PrintSlip("RCP",0);
				StringBuilder builder = new StringBuilder();
				for (int i = 0; i < dataTable.Rows.Count; i++)
				{
					string text = dataTable.Rows[i]["Message"].ToString();
					double num2 = double.Parse(dataTable.Rows[i]["Price"].ToString());
					bool flag = ((int) dataTable.Rows[i]["Bold"]) == 1;
					switch (text)
					{
						case "-":
						case "=":
							slip.Add(text, 1, 0);
							break;

						default:
						{
							builder.Length = 0;
							builder.Append(text);
							if (builder.Length < 0x15)
							{
								builder.Append(new string(' ', 0x15 - builder.Length));
							}
							string str = num2.ToString("f");
							if (str.Length < 10)
							{
								builder.Append(new string(' ', 10 - str.Length));
							}
							builder.Append(str);
							if (flag)
							{
								slip.Add(builder.ToString(), 2, 0);
							}
							else
							{
								slip.Add(builder.ToString(), 1, 0);
							}
							break;
						}
					}
				}
				slip.Print();
			}
		}
		public static void Print(int month, int year)
		{
			SqlConnection connection = ConnectDB.GetConnection();
			SqlCommand selectCommand = new SqlCommand("getTaxSummary", connection);
			selectCommand.CommandType = CommandType.StoredProcedure;
			selectCommand.Parameters.Add("@month", SqlDbType.Int).Value = month;
			selectCommand.Parameters.Add("@year", SqlDbType.Int).Value = year;
			SqlDataAdapter adapter = new SqlDataAdapter(selectCommand);
			DataTable dataTable = new DataTable();
			adapter.Fill(dataTable);
			if (dataTable.Rows.Count == 0)
			{
				connection.Close();
			}
			else
			{
				string str3;
				double num2;
				connection.Close();
				string descriptionByID = CheckBillService.GetDescriptionByID("TAX1");
				string str2 = CheckBillService.GetDescriptionByID("TAX2");
				PrintSlip slip = new PrintSlip("BIL");
				StringBuilder builder = new StringBuilder();
				slip.Add("Tax Monthly Report", 0, 1);
				slip.Add(new DateTime(year, month, 1).ToString("MMMM yyyy", ci), 1, 1);
				slip.Add("", 1, 0);
				builder.Length = 0;
				builder.Append("Day  ");
				if (descriptionByID.Length < 9)
				{
					builder.Append(new string(' ', 9 - descriptionByID.Length));
				}
				builder.Append(descriptionByID);
				if (str2.Length < 9)
				{
					builder.Append(new string(' ', 9 - str2.Length));
				}
				builder.Append(str2);
				slip.Add(builder.ToString(), 1, 0);
				slip.Add("-", 1, 0);
				double num = num2 = 0.0;
				for (int i = 0; i < dataTable.Rows.Count; i++)
				{
					int num4 = (int) dataTable.Rows[i]["invoiceday"];
					double num5 = double.Parse(dataTable.Rows[i]["tax1"].ToString());
					double num6 = double.Parse(dataTable.Rows[i]["tax2"].ToString());
					builder.Length = 0;
					builder.Append(num4);
					if (builder.Length < 5)
					{
						builder.Append(new string(' ', 5 - builder.Length));
					}
					str3 = num5.ToString("f");
					if (str3.Length < 9)
					{
						builder.Append(new string(' ', 9 - str3.Length));
					}
					builder.Append(str3);
					str3 = num6.ToString("f");
					if (str3.Length < 9)
					{
						builder.Append(new string(' ', 9 - str3.Length));
					}
					builder.Append(str3);
					slip.Add(builder.ToString(), 1, 0);
					num += num5;
					num2 += num6;
				}
				slip.Add("-", 1, 0);
				builder.Length = 0;
				builder.Append("Total");
				str3 = num.ToString("f");
				if (str3.Length < 9)
				{
					builder.Append(new string(' ', 9 - str3.Length));
				}
				builder.Append(str3);
				str3 = num2.ToString("f");
				if (str3.Length < 9)
				{
					builder.Append(new string(' ', 9 - str3.Length));
				}
				builder.Append(str3);
				slip.Add(builder.ToString(), 1, 0);
				slip.Add("=", 1, 0);
				slip.Print();
			}
		}