Added Service Tax and CIN Information to the bill printout
Added Nc Option in settlement Merged Vouchers and SaleVoucher table. Need to update the Sql Schema
This commit is contained in:
1 parent
8be15d2d33
commit
0172fc4e01
49 files changed
+1364
-1717
No files matched your search
@@ -0,0 +1,60 @@
|
||||
BEGIN TRANSACTION
|
||||
SET QUOTED_IDENTIFIER ON
|
||||
SET ARITHABORT ON
|
||||
SET NUMERIC_ROUNDABORT OFF
|
||||
SET CONCAT_NULL_YIELDS_NULL ON
|
||||
SET ANSI_NULLS ON
|
||||
SET ANSI_PADDING ON
|
||||
SET ANSI_WARNINGS ON
|
||||
ALTER TABLE dbo.Vouchers DROP CONSTRAINT FK_BasicTransactions_Users_UserID;
|
||||
ALTER TABLE dbo.Vouchers DROP CONSTRAINT DF_BasicTransactions_CreationDate;
|
||||
ALTER TABLE dbo.Vouchers DROP CONSTRAINT DF_BasicTransactions_LastEditDate;
|
||||
CREATE TABLE dbo.Tmp_Vouchers
|
||||
(
|
||||
VoucherID uniqueidentifier NOT NULL PRIMARY KEY,
|
||||
Date datetime NOT NULL,
|
||||
Narration nvarchar(200) NULL,
|
||||
UserID uniqueidentifier NOT NULL,
|
||||
CreationDate datetime NOT NULL,
|
||||
LastEditDate datetime NOT NULL,
|
||||
Floor int NOT NULL,
|
||||
BillID nvarchar(10) NOT NULL,
|
||||
KotID nvarchar(10) NOT NULL,
|
||||
TableID nvarchar(10) NOT NULL,
|
||||
WaiterID uniqueidentifier NOT NULL,
|
||||
CustomerID uniqueidentifier NOT NULL,
|
||||
AdvanceID uniqueidentifier NULL,
|
||||
PaidStatus int NOT NULL,
|
||||
VoidReason nvarchar(50) NULL,
|
||||
Printed bit NOT NULL,
|
||||
Alarm datetime NULL
|
||||
) ON [PRIMARY]
|
||||
INSERT INTO dbo.Tmp_Vouchers (VoucherID, Date, Narration, UserID, CreationDate, LastEditDate, Floor, BillID, KotID, TableID, WaiterID, CustomerID, AdvanceId, PaidStatus, VoidReason, Printed, Alarm)
|
||||
SELECT v.VoucherID, v.Date, v.Narration, v.UserID, v.CreationDate, v.LastEditDate, s.Floor, s.BillID, s.KotID, s.TableID, s.WaiterID, s.CustomerID, s.AdvanceId, s.PaidStatus, s.VoidReason, s.Printed, s.Alarm
|
||||
FROM dbo.Vouchers v INNER JOIN dbo.SaleVoucher s ON v.VoucherID = s.VoucherID;
|
||||
ALTER TABLE dbo.SaleVoucher DROP CONSTRAINT FK_SaleVoucher_Vouchers;
|
||||
ALTER TABLE dbo.Inventory DROP CONSTRAINT FK_Inventory_Vouchers;
|
||||
DROP TABLE dbo.SaleVoucher;
|
||||
DROP TABLE dbo.Vouchers;
|
||||
EXECUTE sp_rename N'dbo.Tmp_Vouchers', N'Vouchers', 'OBJECT';
|
||||
ALTER TABLE dbo.Vouchers ADD CONSTRAINT
|
||||
FK_Vouchers_Users FOREIGN KEY
|
||||
(
|
||||
UserID
|
||||
) REFERENCES dbo.Users
|
||||
(
|
||||
UserID
|
||||
) ON UPDATE NO ACTION
|
||||
ON DELETE NO ACTION
|
||||
|
||||
ALTER TABLE dbo.Inventory ADD CONSTRAINT
|
||||
FK_Inventory_Vouchers FOREIGN KEY
|
||||
(
|
||||
VoucherID
|
||||
) REFERENCES dbo.Vouchers
|
||||
(
|
||||
VoucherID
|
||||
) ON UPDATE NO ACTION
|
||||
ON DELETE NO ACTION
|
||||
ALTER TABLE dbo.ProductGroups DROP COLUMN IsForSale, IsForPurchase;
|
||||
COMMIT
|
||||
@@ -1,57 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Tanshu.Accounts.Contracts;
|
||||
|
||||
|
||||
namespace Tanshu.Accounts.BI
|
||||
{
|
||||
public class AdvanceBI
|
||||
{
|
||||
public void Insert(AdvanceBO advance)
|
||||
{
|
||||
using (var connection = new SqlDAO.SqlConnectionDAO())
|
||||
{
|
||||
using (var dao = new SqlDAO.AdvanceDAO(connection))
|
||||
{
|
||||
dao.Insert(advance);
|
||||
}
|
||||
}
|
||||
}
|
||||
public AdvanceBO Get(Guid advanceID)
|
||||
{
|
||||
|
||||
using (var connection = new SqlDAO.SqlConnectionDAO())
|
||||
{
|
||||
using (var dao = new SqlDAO.AdvanceDAO(connection))
|
||||
{
|
||||
return dao.Get(advanceID);
|
||||
}
|
||||
}
|
||||
}
|
||||
public List<AdvanceDisplayBO> GetAdvances(DateTime fromDate, DateTime toDate, bool all)
|
||||
{
|
||||
fromDate = Convert.ToDateTime(string.Format("{0:dd-MMM-yyyy} 00:00:00", fromDate));
|
||||
toDate = Convert.ToDateTime(string.Format("{0:dd-MMM-yyyy} 23:59:59", toDate));
|
||||
|
||||
using (var connection = new SqlDAO.SqlConnectionDAO())
|
||||
{
|
||||
using (var dao = new SqlDAO.AdvanceDAO(connection))
|
||||
{
|
||||
return dao.GetAdvances(fromDate, toDate, all);
|
||||
}
|
||||
}
|
||||
}
|
||||
public void Adjust(Guid advanceID, Guid userID)
|
||||
{
|
||||
|
||||
using (var connection = new SqlDAO.SqlConnectionDAO())
|
||||
{
|
||||
using (var dao = new SqlDAO.AdvanceDAO(connection))
|
||||
{
|
||||
|
||||
dao.Adjust(advanceID, userID);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -22,6 +22,7 @@ namespace Tanshu.Accounts.BI
|
||||
public decimal AdditionalVoids { get; private set; }
|
||||
public decimal VoidsInSystem { get; private set; }
|
||||
public decimal PendingBills { get; private set; }
|
||||
public decimal NcBills { get; private set; }
|
||||
public decimal NetSales { get; private set; }
|
||||
public decimal ClosingBalance { get; private set; }
|
||||
public decimal RetainedOvernight { get; private set; }
|
||||
@@ -56,6 +57,11 @@ namespace Tanshu.Accounts.BI
|
||||
{
|
||||
get { return _voidsString; }
|
||||
}
|
||||
private readonly string _ncString;
|
||||
public string NcString
|
||||
{
|
||||
get { return _ncString; }
|
||||
}
|
||||
private readonly string _discountString;
|
||||
public string DiscountString
|
||||
{
|
||||
@@ -100,6 +106,7 @@ namespace Tanshu.Accounts.BI
|
||||
|
||||
Cashier = new UserBI().GetUser(CashierID).Name;
|
||||
PendingBills = dao.GetDetail(ref pendingString, PaidStatus.Pending, "\n\r--- Pending Bills ------------------------");
|
||||
NcBills = dao.GetDetail(ref _ncString, PaidStatus.Nc, "\n\r--- No Charge Bills ----------------------");
|
||||
CreditCardReceipts = dao.GetDetail(ref creditCardString, PaidStatus.CreditCard, "\n\r--- Credit Card Bills --------------------");
|
||||
VoidsInSystem = dao.GetDetail(ref _voidsString, PaidStatus.Void, "\n\r--- Void Bills ---------------------------");
|
||||
StaffReceipts = dao.GetDetail(ref _staffString, PaidStatus.Staff, "\n\r--- Staff Bills --------------------------");
|
||||
|
||||
@@ -8,7 +8,6 @@ namespace Tanshu.Accounts.BI
|
||||
{
|
||||
public CustomerBO GetCustomer(Guid customerID)
|
||||
{
|
||||
|
||||
using (var connection = new SqlDAO.SqlConnectionDAO())
|
||||
{
|
||||
using (var dao = new SqlDAO.CustomerDAO(connection))
|
||||
@@ -16,18 +15,6 @@ namespace Tanshu.Accounts.BI
|
||||
return dao.GetCustomer(customerID);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
public List<CustomerBO> GetFilteredCustomers(Dictionary<string, string> filter)
|
||||
{
|
||||
|
||||
using (var connection = new SqlDAO.SqlConnectionDAO())
|
||||
{
|
||||
using (var dao = new SqlDAO.CustomerDAO(connection))
|
||||
{
|
||||
return dao.GetFilteredCustomers(filter);
|
||||
}
|
||||
}
|
||||
}
|
||||
public List<CustomerBO> GetCustomers()
|
||||
{
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Tanshu.Accounts.Contracts;
|
||||
|
||||
namespace Tanshu.Accounts.BI
|
||||
{
|
||||
public class FiltersBI
|
||||
{
|
||||
public List<CustomerBO> GetFilteredCustomers(Dictionary<string, string> filter)
|
||||
{
|
||||
using (var connection = new SqlDAO.SqlConnectionDAO())
|
||||
{
|
||||
using (var dao = new SqlDAO.CustomerDAO(connection))
|
||||
{
|
||||
return dao.GetFilteredCustomers(filter);
|
||||
}
|
||||
}
|
||||
}
|
||||
public List<ProductDisplaySmallBO> GetFilteredProducts(Dictionary<string, string> filter)
|
||||
{
|
||||
using (var connection = new SqlDAO.SqlConnectionDAO())
|
||||
{
|
||||
using (var dao = new SqlDAO.ProductDAO(connection))
|
||||
{
|
||||
return dao.GetFilteredProducts(filter);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -7,7 +7,6 @@ namespace Tanshu.Accounts.BI
|
||||
{
|
||||
public bool ValidateUser(string name, string password)
|
||||
{
|
||||
|
||||
using (var connection = new SqlDAO.SqlConnectionDAO())
|
||||
{
|
||||
using (var dao = new SqlDAO.MembershipDAO(connection))
|
||||
|
||||
@@ -1,130 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Tanshu.Accounts.Contracts;
|
||||
|
||||
namespace Tanshu.Accounts.BI
|
||||
{
|
||||
public class ProductBI
|
||||
{
|
||||
public bool Insert(ProductBO product)
|
||||
{
|
||||
|
||||
using (var connection = new SqlDAO.SqlConnectionDAO())
|
||||
{
|
||||
using (var dao = new SqlDAO.ProductDAO(connection))
|
||||
{
|
||||
return dao.Insert(product);
|
||||
}
|
||||
}
|
||||
}
|
||||
public bool Update(ProductBO product)
|
||||
{
|
||||
|
||||
using (var connection = new SqlDAO.SqlConnectionDAO())
|
||||
{
|
||||
using (var dao = new SqlDAO.ProductDAO(connection))
|
||||
{
|
||||
return dao.Update(product);
|
||||
}
|
||||
}
|
||||
}
|
||||
public bool Delete(Guid productID)
|
||||
{
|
||||
|
||||
using (var connection = new SqlDAO.SqlConnectionDAO())
|
||||
{
|
||||
using (var dao = new SqlDAO.ProductDAO(connection))
|
||||
{
|
||||
return dao.Delete(productID);
|
||||
}
|
||||
}
|
||||
}
|
||||
public ProductBO GetProductFromName(string nameAndUnits)
|
||||
{
|
||||
|
||||
using (var connection = new SqlDAO.SqlConnectionDAO())
|
||||
{
|
||||
using (var dao = new SqlDAO.ProductDAO(connection))
|
||||
{
|
||||
return dao.GetProduct(nameAndUnits);
|
||||
}
|
||||
}
|
||||
}
|
||||
public ProductBO GetProduct(Guid productID)
|
||||
{
|
||||
|
||||
using (var connection = new SqlDAO.SqlConnectionDAO())
|
||||
{
|
||||
using (var dao = new SqlDAO.ProductDAO(connection))
|
||||
{
|
||||
return dao.GetProduct(productID);
|
||||
}
|
||||
}
|
||||
}
|
||||
public List<ProductDisplayBO> GetProducts()
|
||||
{
|
||||
|
||||
using (var connection = new SqlDAO.SqlConnectionDAO())
|
||||
{
|
||||
using (var dao = new SqlDAO.ProductDAO(connection))
|
||||
{
|
||||
return dao.GetProducts();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public List<ProductDisplaySmallBO> GetFilteredProducts(Dictionary<string, string> filter)
|
||||
{
|
||||
|
||||
using (var connection = new SqlDAO.SqlConnectionDAO())
|
||||
{
|
||||
using (var dao = new SqlDAO.ProductDAO(connection))
|
||||
{
|
||||
return dao.GetFilteredProducts(filter);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void UpdateShortName()
|
||||
{
|
||||
|
||||
using (var connection = new SqlDAO.SqlConnectionDAO())
|
||||
{
|
||||
using (var dao = new SqlDAO.ProductDAO(connection))
|
||||
{
|
||||
dao.UpdateShortName();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public List<ProductDisplaySmallBO> GetUnFilteredProducts()
|
||||
{
|
||||
Dictionary<string, string> filter = new Dictionary<string, string>();
|
||||
filter.Add("Name", "");
|
||||
filter.Add("ProductGroup", "");
|
||||
return GetFilteredProducts(filter);
|
||||
}
|
||||
public List<ProductGroupBO> GetProductGroups()
|
||||
{
|
||||
|
||||
using (var connection = new SqlDAO.SqlConnectionDAO())
|
||||
{
|
||||
using (var dao = new SqlDAO.ProductDAO(connection))
|
||||
{
|
||||
return dao.GetProductGroups();
|
||||
}
|
||||
}
|
||||
}
|
||||
public List<TaxBO> GetTaxes()
|
||||
{
|
||||
|
||||
using (var connection = new SqlDAO.SqlConnectionDAO())
|
||||
{
|
||||
using (var dao = new SqlDAO.ProductDAO(connection))
|
||||
{
|
||||
return dao.GetTaxes();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,226 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Tanshu.Accounts.Contracts;
|
||||
|
||||
namespace Tanshu.Accounts.BI
|
||||
{
|
||||
public class SaleVoucherBI
|
||||
{
|
||||
public SalesBillItemBO GetDefaultSaleBillItem(Guid productID)
|
||||
{
|
||||
|
||||
using (var connection = new SqlDAO.SqlConnectionDAO())
|
||||
{
|
||||
using (var dao = new SqlDAO.SaleVoucherMixDAO(connection))
|
||||
{
|
||||
return dao.GetDefaultSaleBillItem(productID);
|
||||
}
|
||||
}
|
||||
}
|
||||
public decimal GetProductDiscountLimit(Guid productID)
|
||||
{
|
||||
|
||||
using (var connection = new SqlDAO.SqlConnectionDAO())
|
||||
{
|
||||
using (var dao = new SqlDAO.SaleVoucherMixDAO(connection))
|
||||
{
|
||||
return dao.GetProductDiscountLimit(productID);
|
||||
}
|
||||
}
|
||||
}
|
||||
public bool IsBillPrinted(Guid voucherID)
|
||||
{
|
||||
|
||||
using (var connection = new SqlDAO.SqlConnectionDAO())
|
||||
{
|
||||
using (var dao = new SqlDAO.SaleVoucherMixDAO(connection))
|
||||
{
|
||||
return dao.IsBillPrinted(voucherID);
|
||||
}
|
||||
}
|
||||
}
|
||||
public decimal Amount(Guid voucherID)
|
||||
{
|
||||
//throw new NotImplementedException();
|
||||
|
||||
using (var connection = new SqlDAO.SqlConnectionDAO())
|
||||
{
|
||||
using (var dao = new SqlDAO.SaleVoucherMixDAO(connection))
|
||||
{
|
||||
return dao.Amount(voucherID);
|
||||
}
|
||||
}
|
||||
}
|
||||
public bool Insert(SaleVoucherBO saleVoucher, List<InventoryBO> inventory)
|
||||
{
|
||||
|
||||
using (var connection = new SqlDAO.SqlConnectionDAO())
|
||||
{
|
||||
using (var vdao = new SqlDAO.VoucherDAO(connection))
|
||||
{
|
||||
using (var svdao = new SqlDAO.SaleVoucherDAO(connection))
|
||||
{
|
||||
using (var idao = new SqlDAO.InventoryDAO(connection))
|
||||
{
|
||||
connection.BeginTransaction();
|
||||
#region Voucher
|
||||
VoucherBO myVoucher = (VoucherBO)saleVoucher;
|
||||
myVoucher.Date = null;
|
||||
vdao.Insert(myVoucher);
|
||||
#endregion
|
||||
#region Transaction Sale
|
||||
svdao.Insert(saleVoucher);
|
||||
#endregion
|
||||
#region Inventory
|
||||
foreach (InventoryBO i in inventory)
|
||||
{
|
||||
i.VoucherID = saleVoucher.VoucherID;
|
||||
InventoryBO myInventory = i;
|
||||
idao.Insert(myInventory);
|
||||
}
|
||||
#endregion
|
||||
connection.CommitTransaction();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
public bool Update(SaleVoucherBO saleVoucher, List<InventoryBO> inventory)
|
||||
{
|
||||
|
||||
using (var connection = new SqlDAO.SqlConnectionDAO())
|
||||
{
|
||||
using (var vdao = new SqlDAO.VoucherDAO(connection))
|
||||
{
|
||||
using (var svdao = new SqlDAO.SaleVoucherDAO(connection))
|
||||
{
|
||||
using (var idao = new SqlDAO.InventoryDAO(connection))
|
||||
{
|
||||
connection.BeginTransaction();
|
||||
#region Voucher
|
||||
VoucherBO myVoucher = (VoucherBO)saleVoucher;
|
||||
vdao.Update(myVoucher);
|
||||
#endregion
|
||||
#region Transaction Sale
|
||||
svdao.Update(saleVoucher);
|
||||
#endregion
|
||||
#region Inventory
|
||||
idao.Delete(saleVoucher.VoucherID);
|
||||
foreach (InventoryBO i in inventory)
|
||||
{
|
||||
i.VoucherID = saleVoucher.VoucherID;
|
||||
InventoryBO myInventory = i;
|
||||
idao.Insert(myInventory);
|
||||
}
|
||||
#endregion
|
||||
connection.CommitTransaction();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
public bool GetSaleVoucher(Guid voucherID, ref SaleVoucherBO voucherSale, ref List<InventoryDisplayBO> iList)
|
||||
{
|
||||
|
||||
using (var connection = new SqlDAO.SqlConnectionDAO())
|
||||
{
|
||||
using (var svdao = new SqlDAO.SaleVoucherDAO(connection))
|
||||
{
|
||||
using (var idao = new SqlDAO.InventoryDAO(connection))
|
||||
{
|
||||
voucherSale = svdao.GetVoucherSale(voucherID);
|
||||
iList = idao.GetInventories(voucherID);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
public bool GetSaleVoucher(string billID, ref SaleVoucherBO voucherSale, ref List<InventoryDisplayBO> iList)
|
||||
{
|
||||
|
||||
using (var connection = new SqlDAO.SqlConnectionDAO())
|
||||
{
|
||||
using (var svdao = new SqlDAO.SaleVoucherDAO(connection))
|
||||
{
|
||||
using (var idao = new SqlDAO.InventoryDAO(connection))
|
||||
{
|
||||
voucherSale = svdao.GetVoucherSale(billID);
|
||||
iList = idao.GetInventories(voucherSale.VoucherID);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public List<PendingBillsBO> GetPendingBills(PendingType list, int floor)
|
||||
{
|
||||
|
||||
using (var connection = new SqlDAO.SqlConnectionDAO())
|
||||
{
|
||||
using (var dao = new SqlDAO.SaleVoucherMixDAO(connection))
|
||||
{
|
||||
return dao.GetPendingBills(list, floor);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public Guid? GetPendingVoucherID(string tableID, int floor)
|
||||
{
|
||||
|
||||
using (var connection = new SqlDAO.SqlConnectionDAO())
|
||||
{
|
||||
using (var dao = new SqlDAO.SaleVoucherMixDAO(connection))
|
||||
{
|
||||
return dao.GetPendingVoucherID(tableID, floor);
|
||||
}
|
||||
}
|
||||
}
|
||||
public List<InventoryBO> SaleInventory(Dictionary<BillItemKey, SalesBillItemBO>.ValueCollection list, Guid? voucherID)
|
||||
{
|
||||
|
||||
using (var connection = new SqlDAO.SqlConnectionDAO())
|
||||
{
|
||||
using (var dao = new SqlDAO.SaleVoucherMixDAO(connection))
|
||||
{
|
||||
return dao.SaleInventory(list, voucherID);
|
||||
}
|
||||
}
|
||||
}
|
||||
public void SetAlarm(Guid voucherID, DateTime? alarmTime)
|
||||
{
|
||||
|
||||
using (var connection = new SqlDAO.SqlConnectionDAO())
|
||||
{
|
||||
using (var dao = new SqlDAO.SaleVoucherDAO(connection))
|
||||
{
|
||||
dao.SetAlarm(voucherID, alarmTime);
|
||||
}
|
||||
}
|
||||
}
|
||||
public void VoidBill(Guid voucherID, string reason, Guid userID)
|
||||
{
|
||||
|
||||
using (var connection = new SqlDAO.SqlConnectionDAO())
|
||||
{
|
||||
using (var dao = new SqlDAO.SaleVoucherDAO(connection))
|
||||
{
|
||||
dao.VoidBill(voucherID, reason, userID);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void DeclareBillsPaid(Guid userID, List<Guid> billList, PaidStatus paidStatus)
|
||||
{
|
||||
|
||||
using (var connection = new SqlDAO.SqlConnectionDAO())
|
||||
{
|
||||
using (var dao = new SqlDAO.SaleVoucherMixDAO(connection))
|
||||
{
|
||||
dao.DeclareBillsPaid(userID, billList, paidStatus);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -8,7 +8,6 @@ namespace Tanshu.Accounts.BI
|
||||
{
|
||||
public List<SalesAnalysisDetailBO> GetSaleDetail(DateTime startDate, DateTime finishDate, Guid productGroupID)
|
||||
{
|
||||
|
||||
using (var connection = new SqlDAO.SqlConnectionDAO())
|
||||
{
|
||||
using (var dao = new SqlDAO.SalesAnalysisDAO(connection))
|
||||
@@ -29,25 +28,14 @@ namespace Tanshu.Accounts.BI
|
||||
}
|
||||
}
|
||||
}
|
||||
public decimal GetFreeSale(DateTime startDate, DateTime finishDate)
|
||||
public List<SalesAnalysisBO> GetSalesTaxReturn(DateTime startDate, DateTime finishDate, ref decimal voids, ref decimal pending, ref decimal net, ref decimal vat, ref decimal serviceTax, ref decimal nc)
|
||||
{
|
||||
|
||||
using (var connection = new SqlDAO.SqlConnectionDAO())
|
||||
{
|
||||
using (var dao = new SqlDAO.SalesAnalysisDAO(connection))
|
||||
{
|
||||
return dao.GetFreeSale(startDate, finishDate);
|
||||
}
|
||||
}
|
||||
}
|
||||
public List<SalesAnalysisBO> GetSalesTaxReturn(DateTime startDate, DateTime finishDate, ref decimal freeSale, ref decimal voids, ref decimal pending, ref decimal net, ref decimal tax)
|
||||
{
|
||||
|
||||
using (var connection = new SqlDAO.SqlConnectionDAO())
|
||||
{
|
||||
using (var dao = new SqlDAO.SalesAnalysisDAO(connection))
|
||||
{
|
||||
return dao.GetSalesTaxReturn(startDate, finishDate, ref freeSale, ref voids, ref pending, ref net, ref tax);
|
||||
return dao.GetSalesTaxReturn(startDate, finishDate, ref voids, ref pending, ref net, ref vat, ref serviceTax, ref nc);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -62,19 +62,18 @@
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="AdvanceBI.cs" />
|
||||
<Compile Include="CheckoutBI.cs" />
|
||||
<Compile Include="CustomerBI.cs" />
|
||||
<Compile Include="FiltersBI.cs" />
|
||||
<Compile Include="ManagementBI.cs" />
|
||||
<Compile Include="RoleBI.cs" />
|
||||
<Compile Include="SecurityBI.cs" />
|
||||
<Compile Include="VoucherBI.cs" />
|
||||
<Compile Include="WaiterBI.cs" />
|
||||
<Compile Include="MembershipBI.cs" />
|
||||
<Compile Include="PaymentBI.cs" />
|
||||
<Compile Include="ProductBI.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="SalesAnalysisBI.cs" />
|
||||
<Compile Include="SaleVoucherBI.cs" />
|
||||
<Compile Include="UserBI.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
|
||||
@@ -0,0 +1,202 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Tanshu.Accounts.Contracts;
|
||||
using Tanshu.Accounts.SqlDAO;
|
||||
|
||||
namespace Tanshu.Accounts.BI
|
||||
{
|
||||
public class VoucherBI
|
||||
{
|
||||
public VoucherBO Insert(VoucherBO voucher)
|
||||
{
|
||||
using (var connection = new SqlDAO.SqlConnectionDAO())
|
||||
{
|
||||
using (var vdao = new SqlDAO.VoucherDAO(connection))
|
||||
{
|
||||
using (var idao = new SqlDAO.InventoryDAO(connection))
|
||||
{
|
||||
using (var advdao = new SqlDAO.AdvanceDAO(connection))
|
||||
{
|
||||
connection.BeginTransaction();
|
||||
voucher.Date = null;
|
||||
vdao.Insert(voucher);
|
||||
foreach (var i in voucher.Inventories)
|
||||
{
|
||||
i.VoucherID = voucher.VoucherID;
|
||||
idao.Insert(i);
|
||||
}
|
||||
if (voucher.AdvanceID.HasValue)
|
||||
advdao.Adjust(voucher.AdvanceID.Value, CurrentUser.user.UserID);
|
||||
connection.CommitTransaction();
|
||||
return GetVoucher(voucher.VoucherID);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
public VoucherBO Update(VoucherBO voucher)
|
||||
{
|
||||
|
||||
using (var connection = new SqlDAO.SqlConnectionDAO())
|
||||
{
|
||||
using (var vdao = new SqlDAO.VoucherDAO(connection))
|
||||
{
|
||||
using (var idao = new SqlDAO.InventoryDAO(connection))
|
||||
{
|
||||
using (var advdao = new SqlDAO.AdvanceDAO(connection))
|
||||
{
|
||||
connection.BeginTransaction();
|
||||
vdao.Update(voucher);
|
||||
idao.Delete(voucher.VoucherID);
|
||||
foreach (InventoryBO i in voucher.Inventories)
|
||||
{
|
||||
i.VoucherID = voucher.VoucherID;
|
||||
idao.Insert(i);
|
||||
}
|
||||
if (voucher.AdvanceID.HasValue)
|
||||
advdao.Adjust(voucher.AdvanceID.Value, CurrentUser.user.UserID);
|
||||
connection.CommitTransaction();
|
||||
return GetVoucher(voucher.VoucherID);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
public VoucherBO GetVoucher(Guid voucherID)
|
||||
{
|
||||
using (var connection = new SqlDAO.SqlConnectionDAO())
|
||||
{
|
||||
using (var vdao = new SqlDAO.VoucherDAO(connection))
|
||||
{
|
||||
var voucher = new VoucherBO();
|
||||
voucher = vdao.GetVoucher(voucherID);
|
||||
return FillVoucher(voucher, connection);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
public VoucherBO GetVoucher(string billID)
|
||||
{
|
||||
using (var connection = new SqlDAO.SqlConnectionDAO())
|
||||
{
|
||||
using (var vdao = new SqlDAO.VoucherDAO(connection))
|
||||
{
|
||||
var voucher = new VoucherBO();
|
||||
voucher = vdao.GetVoucher(billID);
|
||||
return FillVoucher(voucher, connection);
|
||||
}
|
||||
}
|
||||
}
|
||||
private VoucherBO FillVoucher(VoucherBO voucher, SqlConnectionDAO connection)
|
||||
{
|
||||
using (var idao = new SqlDAO.InventoryDAO(connection))
|
||||
{
|
||||
using (var adao = new SqlDAO.AdvanceDAO(connection))
|
||||
{
|
||||
using (var wdao = new SqlDAO.WaiterDAO(connection))
|
||||
{
|
||||
using (var udao = new SqlDAO.UserDAO(connection))
|
||||
{
|
||||
using (var cdao = new SqlDAO.CustomerDAO(connection))
|
||||
{
|
||||
voucher.Inventories = idao.GetInventories(voucher.VoucherID);
|
||||
if (voucher.AdvanceID.HasValue)
|
||||
voucher.Advance = adao.Get(voucher.AdvanceID.Value);
|
||||
voucher.Waiter = wdao.GetWaiter(voucher.WaiterID);
|
||||
voucher.User = udao.GetUser(voucher.UserID);
|
||||
voucher.Customer = cdao.GetCustomer(voucher.CustomerID);
|
||||
return voucher;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public List<PendingBillsBO> GetPendingBills(PendingType list, int floor)
|
||||
{
|
||||
|
||||
using (var connection = new SqlDAO.SqlConnectionDAO())
|
||||
{
|
||||
using (var dao = new SqlDAO.VoucherDAO(connection))
|
||||
{
|
||||
return dao.GetPendingBills(list, floor);
|
||||
}
|
||||
}
|
||||
}
|
||||
public Guid? GetPendingVoucherID(string tableID, int floor)
|
||||
{
|
||||
|
||||
using (var connection = new SqlDAO.SqlConnectionDAO())
|
||||
{
|
||||
using (var dao = new SqlDAO.VoucherDAO(connection))
|
||||
{
|
||||
return dao.GetPendingVoucherID(tableID, floor);
|
||||
}
|
||||
}
|
||||
}
|
||||
public List<InventoryBO> SaleInventory(Dictionary<BillItemKey, SalesBillItemBO>.ValueCollection list, Guid? voucherID)
|
||||
{
|
||||
var localList = new Dictionary<Guid, InventoryBO>();
|
||||
foreach (var item in list)
|
||||
{
|
||||
var temp = new InventoryBO();
|
||||
if (localList.ContainsKey(item.productID))
|
||||
{
|
||||
temp = localList[item.productID];
|
||||
temp.Quantity += item.Quantity;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (voucherID.HasValue)
|
||||
temp.VoucherID = voucherID.Value;
|
||||
temp.InventoryID = Guid.NewGuid();
|
||||
temp.Discount = item.Discount;
|
||||
temp.ProductID = item.productID;
|
||||
temp.Quantity = item.Quantity;
|
||||
temp.Rate = item.Price;
|
||||
temp.Vat = item.Vat;
|
||||
temp.ServiceTax = item.ServiceTax;
|
||||
localList.Add(item.productID, temp);
|
||||
}
|
||||
}
|
||||
var outList = new List<InventoryBO>();
|
||||
foreach (var item in localList)
|
||||
outList.Add(item.Value);
|
||||
return outList;
|
||||
}
|
||||
public void SetAlarm(Guid voucherID, DateTime? alarmTime)
|
||||
{
|
||||
|
||||
using (var connection = new SqlDAO.SqlConnectionDAO())
|
||||
{
|
||||
using (var dao = new SqlDAO.VoucherDAO(connection))
|
||||
{
|
||||
dao.SetAlarm(voucherID, alarmTime);
|
||||
}
|
||||
}
|
||||
}
|
||||
public void VoidBill(Guid voucherID, string reason, Guid userID)
|
||||
{
|
||||
|
||||
using (var connection = new SqlDAO.SqlConnectionDAO())
|
||||
{
|
||||
using (var dao = new SqlDAO.VoucherDAO(connection))
|
||||
{
|
||||
dao.VoidBill(voucherID, reason, userID);
|
||||
}
|
||||
}
|
||||
}
|
||||
public void DeclareBillsPaid(Guid userID, List<Guid> billList, PaidStatus paidStatus)
|
||||
{
|
||||
|
||||
using (var connection = new SqlDAO.SqlConnectionDAO())
|
||||
{
|
||||
using (var dao = new SqlDAO.VoucherDAO(connection))
|
||||
{
|
||||
dao.DeclareBillsPaid(userID, billList, paidStatus);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -6,19 +6,12 @@ namespace Tanshu.Accounts.Contracts
|
||||
|
||||
public class CustomerBO
|
||||
{
|
||||
|
||||
public Guid CustomerID { get; set; }
|
||||
|
||||
public int Code { get; set; }
|
||||
|
||||
public string Name { get; set; }
|
||||
|
||||
public string Address { get; set; }
|
||||
|
||||
public bool Important { get; set; }
|
||||
|
||||
public string Phone { get; set; }
|
||||
|
||||
public string Remarks { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -6,73 +6,66 @@ namespace Tanshu.Accounts.Contracts
|
||||
|
||||
public class InventoryBO
|
||||
{
|
||||
|
||||
public Guid InventoryID { get; set; }
|
||||
|
||||
public Guid VoucherID { get; set; }
|
||||
|
||||
public Guid ProductID { get; set; }
|
||||
public string ProductName { get; set; }
|
||||
private decimal quantity;
|
||||
|
||||
public decimal Quantity
|
||||
{
|
||||
get { return quantity; }
|
||||
set
|
||||
{
|
||||
quantity = value;
|
||||
if (amount != null)
|
||||
CalculateAmount();
|
||||
amount = null;
|
||||
}
|
||||
}
|
||||
private decimal rate;
|
||||
|
||||
private decimal rate;
|
||||
public decimal Rate
|
||||
{
|
||||
get { return rate; }
|
||||
set
|
||||
{
|
||||
rate = value;
|
||||
if (amount != null)
|
||||
CalculateAmount();
|
||||
amount = null;
|
||||
}
|
||||
}
|
||||
decimal vat;
|
||||
|
||||
decimal vat;
|
||||
public decimal Vat
|
||||
{
|
||||
get { return vat; }
|
||||
set
|
||||
{
|
||||
vat = value; if (amount != null)
|
||||
CalculateAmount();
|
||||
vat = value;
|
||||
amount = null;
|
||||
}
|
||||
}
|
||||
decimal serviceTax;
|
||||
|
||||
decimal serviceTax;
|
||||
public decimal ServiceTax
|
||||
{
|
||||
get { return serviceTax; }
|
||||
set
|
||||
{
|
||||
serviceTax = value; if (amount != null)
|
||||
CalculateAmount();
|
||||
serviceTax = value;
|
||||
amount = null;
|
||||
}
|
||||
}
|
||||
|
||||
decimal discount;
|
||||
|
||||
|
||||
public decimal Discount
|
||||
{
|
||||
get { return discount; }
|
||||
set
|
||||
{
|
||||
discount = value; if (amount != null)
|
||||
CalculateAmount();
|
||||
discount = value;
|
||||
amount = null;
|
||||
}
|
||||
}
|
||||
decimal? amount;
|
||||
|
||||
|
||||
decimal? amount;
|
||||
public decimal Amount
|
||||
{
|
||||
get
|
||||
|
||||
@@ -1,12 +0,0 @@
|
||||
using System;
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
namespace Tanshu.Accounts.Contracts
|
||||
{
|
||||
|
||||
public class InventoryDisplayBO : InventoryBO
|
||||
{
|
||||
|
||||
public string ProductName { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -7,6 +7,7 @@
|
||||
CreditCard = 3,
|
||||
Credit = 4,
|
||||
Staff = 5,
|
||||
Void = 6
|
||||
Void = 6,
|
||||
Nc = 7
|
||||
}
|
||||
}
|
||||
@@ -11,8 +11,8 @@ namespace Tanshu.Accounts.Contracts
|
||||
public string Units { get; set; }
|
||||
public Guid ProductGroupID { get; set; }
|
||||
public Guid VatID { get; set; }
|
||||
public decimal SalePrice { get; set; }
|
||||
public Guid ServiceTaxID { get; set; }
|
||||
public decimal SalePrice { get; set; }
|
||||
public bool Discontinued { get; set; }
|
||||
public int SortOrder { get; set; }
|
||||
}
|
||||
|
||||
@@ -5,12 +5,12 @@ namespace Tanshu.Accounts.Contracts
|
||||
{
|
||||
public class ProductDisplaySmallBO
|
||||
{
|
||||
public Guid ProductID { get; set; }
|
||||
public int Code { get; set; }
|
||||
public string Name { get; set; }
|
||||
public decimal Price { get; set; }
|
||||
public string ProuctGroup { get; set; }
|
||||
public string Vat { get; set; }
|
||||
public string ServiceTax { get; set; }
|
||||
public Guid ProductID { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -8,7 +8,5 @@ namespace Tanshu.Accounts.Contracts
|
||||
public Guid ProductGroupID { get; set; }
|
||||
public string Name { get; set; }
|
||||
public decimal DiscountLimit { get; set; }
|
||||
public bool IsForSale { get; set; }
|
||||
public bool IsForPurchae { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
using System;
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
namespace Tanshu.Accounts.Contracts
|
||||
{
|
||||
public class SaleVoucherBO : VoucherBO
|
||||
{
|
||||
public int Floor { get; set; }
|
||||
public string BillID { get; set; }
|
||||
public string TableID { get; set; }
|
||||
public Guid WaiterID { get; set; }
|
||||
public Guid CustomerID { get; set; }
|
||||
public Guid? AdvanceID { get; set; }
|
||||
public PaidStatus PaidStatus { get; set; }
|
||||
public string VoidReason { get; set; }
|
||||
public bool Printed { get; set; }
|
||||
public DateTime? Alarm { get; set; }
|
||||
public string KotID { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -6,13 +6,10 @@ namespace Tanshu.Accounts.Contracts
|
||||
|
||||
public class SalesBillItemBO
|
||||
{
|
||||
|
||||
public Guid productID;
|
||||
|
||||
public string Name { get; set; }
|
||||
|
||||
private decimal price;
|
||||
|
||||
public decimal Price
|
||||
{
|
||||
get { return price; }
|
||||
@@ -26,7 +23,6 @@ namespace Tanshu.Accounts.Contracts
|
||||
}
|
||||
|
||||
private decimal quantity = 1;
|
||||
|
||||
public decimal Quantity
|
||||
{
|
||||
get { return quantity; }
|
||||
@@ -40,7 +36,6 @@ namespace Tanshu.Accounts.Contracts
|
||||
}
|
||||
|
||||
private decimal discount = 0;
|
||||
|
||||
public decimal Discount
|
||||
{
|
||||
get { return discount; }
|
||||
@@ -57,22 +52,20 @@ namespace Tanshu.Accounts.Contracts
|
||||
|
||||
|
||||
public decimal Vat { get; set; }
|
||||
|
||||
public decimal VatAmount
|
||||
{
|
||||
get
|
||||
{
|
||||
return quantity * price * Vat * (1 - discount);
|
||||
return quantity * price * (1 - discount) * Vat;
|
||||
}
|
||||
}
|
||||
|
||||
public decimal ServiceTax { get; set; }
|
||||
|
||||
public decimal ServiceTaxAmount
|
||||
{
|
||||
get
|
||||
{
|
||||
return quantity * price * ServiceTax * (1 - discount);
|
||||
return quantity * price * (1 - discount) * ServiceTax;
|
||||
}
|
||||
}
|
||||
public decimal TotalTax
|
||||
@@ -100,7 +93,6 @@ namespace Tanshu.Accounts.Contracts
|
||||
}
|
||||
|
||||
private decimal printed = 0;
|
||||
|
||||
public decimal Printed
|
||||
{
|
||||
get { return printed; }
|
||||
@@ -113,13 +105,11 @@ namespace Tanshu.Accounts.Contracts
|
||||
}
|
||||
}
|
||||
|
||||
public string location;
|
||||
|
||||
public decimal Value
|
||||
{
|
||||
get
|
||||
{
|
||||
return price * quantity * (1 - discount) * (1 + Vat + ServiceTax );
|
||||
return price * quantity * (1 - discount) * (1 + Vat + ServiceTax);
|
||||
}
|
||||
}
|
||||
public decimal Additional
|
||||
|
||||
@@ -1,18 +0,0 @@
|
||||
using System;
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
namespace Tanshu.Accounts.Contracts
|
||||
{
|
||||
public class VerificationBO
|
||||
{
|
||||
public Guid VerificationID { get; set; }
|
||||
public Guid VoucherID { get; set; }
|
||||
public Guid ProductID { get; set; }
|
||||
public decimal ActualQuantity { get; set; }
|
||||
public decimal ComputedQuantity { get; set; }
|
||||
public decimal LostQuantity
|
||||
{
|
||||
get { return ComputedQuantity - ActualQuantity; }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
using System;
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
namespace Tanshu.Accounts.Contracts
|
||||
{
|
||||
public class VerificationDisplayBO : VerificationBO
|
||||
{
|
||||
public string ProductName { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -1,24 +1,51 @@
|
||||
using System;
|
||||
using System.Runtime.Serialization;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Tanshu.Accounts.Contracts
|
||||
{
|
||||
|
||||
public class VoucherBO
|
||||
{
|
||||
|
||||
public Guid VoucherID { get; set; }
|
||||
|
||||
public int Code { get; set; }
|
||||
|
||||
public DateTime? Date { get; set; }
|
||||
|
||||
public string Narration { get; set; }
|
||||
|
||||
public Guid UserID { get; set; }
|
||||
|
||||
public DateTime CreationDate { get; set; }
|
||||
|
||||
public DateTime LastEditDate { get; set; }
|
||||
|
||||
public int Floor { get; set; }
|
||||
public string BillID { get; set; }
|
||||
public string TableID { get; set; }
|
||||
public Guid WaiterID { get; set; }
|
||||
public Guid CustomerID { get; set; }
|
||||
public Guid? AdvanceID { get; set; }
|
||||
public PaidStatus PaidStatus { get; set; }
|
||||
public string VoidReason { get; set; }
|
||||
public bool Printed { get; set; }
|
||||
public DateTime? Alarm { get; set; }
|
||||
public string KotID { get; set; }
|
||||
|
||||
public IList<InventoryBO> Inventories { get; set; }
|
||||
public AdvanceBO Advance { get; set; }
|
||||
public WaiterBO Waiter { get; set; }
|
||||
public UserBO User { get; set; }
|
||||
public CustomerBO Customer { get; set; }
|
||||
public decimal Amount
|
||||
{
|
||||
get
|
||||
{
|
||||
decimal amount = 0;
|
||||
foreach (var inv in Inventories)
|
||||
{
|
||||
amount += inv.Amount;
|
||||
}
|
||||
if (AdvanceID.HasValue)
|
||||
{
|
||||
amount -= Advance.Amount;
|
||||
}
|
||||
return amount;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -59,12 +59,9 @@
|
||||
<Compile Include="Data Contracts\BillItemKey.cs" />
|
||||
<Compile Include="Data Contracts\PaidStatusBO.cs" />
|
||||
<Compile Include="Data Contracts\TaxBO.cs" />
|
||||
<Compile Include="Data Contracts\VerificationBO.cs" />
|
||||
<Compile Include="Data Contracts\VerificationDisplayBO.cs" />
|
||||
<Compile Include="Data Contracts\CustomerBO.cs" />
|
||||
<Compile Include="Data Contracts\WaiterBO.cs" />
|
||||
<Compile Include="Data Contracts\InventoryBO.cs" />
|
||||
<Compile Include="Data Contracts\InventoryDisplayBO.cs" />
|
||||
<Compile Include="Data Contracts\PaymentBO.cs" />
|
||||
<Compile Include="Data Contracts\PaymentDisplayBO.cs" />
|
||||
<Compile Include="Data Contracts\PendingBillsBO.cs" />
|
||||
@@ -75,7 +72,6 @@
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="Data Contracts\SalesAnalysisBO.cs" />
|
||||
<Compile Include="Data Contracts\SalesBillItemBO.cs" />
|
||||
<Compile Include="Data Contracts\SaleVoucherBO.cs" />
|
||||
<Compile Include="Data Contracts\UserBO.cs" />
|
||||
<Compile Include="Data Contracts\VoucherBO.cs" />
|
||||
</ItemGroup>
|
||||
|
||||
@@ -48,7 +48,13 @@ namespace Tanshu.Accounts.PointOfSale
|
||||
}
|
||||
else
|
||||
{
|
||||
new ProductBI().UpdateShortName();
|
||||
using (var connection = new SqlDAO.SqlConnectionDAO())
|
||||
{
|
||||
using (var dao = new SqlDAO.ProductDAO(connection))
|
||||
{
|
||||
dao.UpdateShortName();
|
||||
}
|
||||
}
|
||||
using (var frmSale = new SalesForm())
|
||||
frmSale.ShowDialog();
|
||||
}
|
||||
@@ -208,7 +214,7 @@ namespace Tanshu.Accounts.PointOfSale
|
||||
}
|
||||
else
|
||||
{
|
||||
using (SelectProduct selectProduct = new SelectProduct(new ProductBI().GetFilteredProducts, false))
|
||||
using (SelectProduct selectProduct = new SelectProduct(new FiltersBI().GetFilteredProducts, false))
|
||||
{
|
||||
selectProduct.productEvent += new ProductEventHandler(selectProduct_productEvent);
|
||||
selectProduct.ShowDialog();
|
||||
|
||||
@@ -27,7 +27,14 @@ namespace Tanshu.Accounts.PointOfSale
|
||||
FillCombos();
|
||||
if (_productID.HasValue)
|
||||
{
|
||||
product = new ProductBI().GetProduct(_productID.Value);
|
||||
using (var connection = new SqlDAO.SqlConnectionDAO())
|
||||
{
|
||||
using (var dao = new SqlDAO.ProductDAO(connection))
|
||||
{
|
||||
product = dao.GetProduct(_productID.Value);
|
||||
}
|
||||
}
|
||||
|
||||
txtUniqueID.Text = product.Code.ToString();
|
||||
txtName.Text = product.Name;
|
||||
cmbUnits.SelectedItem = product.Units;
|
||||
@@ -50,9 +57,15 @@ namespace Tanshu.Accounts.PointOfSale
|
||||
{
|
||||
string[] units = { "Can", "Gms", "Rs.", "Piece", "Liter", "Plate", "Kg.", "Bottle", "Pack" };
|
||||
bsUnits.DataSource = units;
|
||||
bsProductGroups.DataSource = new ProductBI().GetProductGroups();
|
||||
bsVat.DataSource = new ProductBI().GetTaxes();
|
||||
bsServiceTax.DataSource = new ProductBI().GetTaxes();
|
||||
using (var connection = new SqlDAO.SqlConnectionDAO())
|
||||
{
|
||||
using (var dao = new SqlDAO.ProductDAO(connection))
|
||||
{
|
||||
bsProductGroups.DataSource = dao.GetProductGroups();
|
||||
bsVat.DataSource = dao.GetTaxes();
|
||||
bsServiceTax.DataSource = dao.GetTaxes();
|
||||
}
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
@@ -62,9 +75,16 @@ namespace Tanshu.Accounts.PointOfSale
|
||||
if (MessageBox.Show("Are you sure?", "Delete", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) != DialogResult.Yes)
|
||||
return;
|
||||
|
||||
if (new ProductBI().Delete(product.ProductID))
|
||||
|
||||
using (var connection = new SqlDAO.SqlConnectionDAO())
|
||||
{
|
||||
btnCancel_Click(sender, e);
|
||||
using (var dao = new SqlDAO.ProductDAO(connection))
|
||||
{
|
||||
if (dao.Delete(product.ProductID))
|
||||
{
|
||||
btnCancel_Click(sender, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -105,10 +125,16 @@ namespace Tanshu.Accounts.PointOfSale
|
||||
product.ServiceTaxID = new Guid(cmbServiceTax.SelectedValue.ToString());
|
||||
product.Discontinued = chkDiscontinued.Checked;
|
||||
product.VatID = new Guid(cmbVat.SelectedValue.ToString());
|
||||
if (product.ProductID == new Guid())
|
||||
new ProductBI().Insert(product);
|
||||
else
|
||||
new ProductBI().Update(product);
|
||||
using (var connection = new SqlDAO.SqlConnectionDAO())
|
||||
{
|
||||
using (var dao = new SqlDAO.ProductDAO(connection))
|
||||
{
|
||||
if (product.ProductID == new Guid())
|
||||
dao.Insert(product);
|
||||
else
|
||||
dao.Update(product);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
@@ -120,16 +120,25 @@
|
||||
<metadata name="bsProductGroups.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>251, 17</value>
|
||||
</metadata>
|
||||
<metadata name="bsProductGroups.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>251, 17</value>
|
||||
</metadata>
|
||||
<metadata name="bsUnits.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>123, 17</value>
|
||||
<value>29, 15</value>
|
||||
</metadata>
|
||||
<metadata name="bsUnits.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>29, 15</value>
|
||||
</metadata>
|
||||
<metadata name="bsVat.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>145, 54</value>
|
||||
<value>132, 16</value>
|
||||
</metadata>
|
||||
<metadata name="bsServiceTax.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>438, 54</value>
|
||||
<value>434, 13</value>
|
||||
</metadata>
|
||||
<metadata name="bsServiceTax.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>434, 13</value>
|
||||
</metadata>
|
||||
<metadata name="$this.TrayHeight" type="System.Int32, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>102</value>
|
||||
<value>65</value>
|
||||
</metadata>
|
||||
</root>
|
||||
@@ -29,7 +29,15 @@ namespace Tanshu.Accounts.PointOfSale
|
||||
}
|
||||
private void FillDataGrid()
|
||||
{
|
||||
dgExpenses.DataSource = new AdvanceBI().GetAdvances(dtpFrom.Value, dtpTo.Value, false);
|
||||
var fromDate = Convert.ToDateTime(string.Format("{0:dd-MMM-yyyy} 00:00:00", dtpFrom.Value));
|
||||
var toDate = Convert.ToDateTime(string.Format("{0:dd-MMM-yyyy} 23:59:59", dtpTo.Value));
|
||||
using (var connection = new SqlDAO.SqlConnectionDAO())
|
||||
{
|
||||
using (var dao = new SqlDAO.AdvanceDAO(connection))
|
||||
{
|
||||
dgExpenses.DataSource = dao.GetAdvances(fromDate, toDate, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
private void dtpFrom_ValueChanged(object sender, EventArgs e)
|
||||
{
|
||||
@@ -61,7 +69,13 @@ namespace Tanshu.Accounts.PointOfSale
|
||||
}
|
||||
else
|
||||
{
|
||||
new AdvanceBI().Adjust((Guid)txtNarration.Tag, CurrentUser.user.UserID);
|
||||
using (var connection = new SqlDAO.SqlConnectionDAO())
|
||||
{
|
||||
using (var dao = new SqlDAO.AdvanceDAO(connection))
|
||||
{
|
||||
dao.Adjust((Guid)txtNarration.Tag, CurrentUser.user.UserID);
|
||||
}
|
||||
}
|
||||
FillDataGrid();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,7 +30,20 @@ namespace Tanshu.Accounts.PointOfSale
|
||||
#endregion
|
||||
|
||||
#region Max Discount
|
||||
var maxDiscount = new SaleVoucherBI().GetProductDiscountLimit(productID);
|
||||
decimal maxDiscount;
|
||||
using (var connection = new SqlDAO.SqlConnectionDAO())
|
||||
{
|
||||
using (var dao = new SqlDAO.ProductDAO(connection))
|
||||
{
|
||||
maxDiscount = dao.GetProductDiscountLimit(productID);
|
||||
}
|
||||
}
|
||||
|
||||
if (discount >= 1)
|
||||
{
|
||||
MessageBox.Show(string.Format("Discount cannot be 100% or more", maxDiscount), "100% Discount", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
if (discount > maxDiscount)
|
||||
{
|
||||
if (Thread.CurrentPrincipal.IsInRole("High Discount Allowed"))
|
||||
@@ -107,7 +120,14 @@ namespace Tanshu.Accounts.PointOfSale
|
||||
private static SalesBillItemBO AddNewProduct(Guid productID, BindingSource bindingSource, Dictionary<BillItemKey, SalesBillItemBO> bill)
|
||||
{
|
||||
BillItemKey key = new BillItemKey(productID, true);
|
||||
SalesBillItemBO product = new SaleVoucherBI().GetDefaultSaleBillItem(productID);
|
||||
SalesBillItemBO product;
|
||||
using (var connection = new SqlDAO.SqlConnectionDAO())
|
||||
{
|
||||
using (var dao = new SqlDAO.ProductDAO(connection))
|
||||
{
|
||||
product = dao.GetDefaultSaleBillItem(productID);
|
||||
}
|
||||
}
|
||||
product.Quantity = 1;
|
||||
bill.Add(key, product);
|
||||
bindingSource.DataSource = bill.Values;
|
||||
|
||||
@@ -33,7 +33,13 @@ namespace Tanshu.Accounts.PointOfSale
|
||||
}
|
||||
else
|
||||
{
|
||||
new AdvanceBI().Insert(adv);
|
||||
using (var connection = new SqlDAO.SqlConnectionDAO())
|
||||
{
|
||||
using (var dao = new SqlDAO.AdvanceDAO(connection))
|
||||
{
|
||||
dao.Insert(adv);
|
||||
}
|
||||
}
|
||||
GridBind();
|
||||
PrintAdvances();
|
||||
}
|
||||
@@ -56,8 +62,15 @@ namespace Tanshu.Accounts.PointOfSale
|
||||
|
||||
private void GridBind()
|
||||
{
|
||||
var advance = new AdvanceBI().GetAdvances(dtpFrom.Value, dtpTo.Value, true);
|
||||
dgExpenses.DataSource = advance;
|
||||
var fromDate = Convert.ToDateTime(string.Format("{0:dd-MMM-yyyy} 00:00:00", dtpFrom.Value));
|
||||
var toDate = Convert.ToDateTime(string.Format("{0:dd-MMM-yyyy} 23:59:59", dtpTo.Value));
|
||||
using (var connection = new SqlDAO.SqlConnectionDAO())
|
||||
{
|
||||
using (var dao = new SqlDAO.AdvanceDAO(connection))
|
||||
{
|
||||
dgExpenses.DataSource = dao.GetAdvances(fromDate, toDate, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void dtpFrom_ValueChanged(object sender, EventArgs e)
|
||||
|
||||
@@ -48,11 +48,6 @@ namespace Tanshu.Accounts.PointOfSale
|
||||
dgvSale.Columns[2].DefaultCellStyle.Format = "#,##0.00;(#,##0.00);0";
|
||||
dgvSale.Columns[3].DefaultCellStyle.Format = "#,##0.00;(#,##0.00);0";
|
||||
}
|
||||
|
||||
|
||||
decimal freeSale = new SalesAnalysisBI().GetFreeSale(startDate, finishDate);
|
||||
|
||||
txtFreeSale.Text = String.Format("{0:#,##0.00;(#,##0.00);0}", freeSale);
|
||||
}
|
||||
|
||||
private void dtpFinish_ValueChanged(object sender, EventArgs e)
|
||||
|
||||
+1
-24
@@ -28,8 +28,6 @@
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.txtFreeSale = new System.Windows.Forms.TextBox();
|
||||
this.label4 = new System.Windows.Forms.Label();
|
||||
this.dgvSale = new System.Windows.Forms.DataGridView();
|
||||
this.dtpFinish = new System.Windows.Forms.DateTimePicker();
|
||||
this.dtpStart = new System.Windows.Forms.DateTimePicker();
|
||||
@@ -39,23 +37,6 @@
|
||||
((System.ComponentModel.ISupportInitialize)(this.dgvSale)).BeginInit();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// txtFreeSale
|
||||
//
|
||||
this.txtFreeSale.Location = new System.Drawing.Point(12, 487);
|
||||
this.txtFreeSale.Name = "txtFreeSale";
|
||||
this.txtFreeSale.ReadOnly = true;
|
||||
this.txtFreeSale.Size = new System.Drawing.Size(100, 20);
|
||||
this.txtFreeSale.TabIndex = 15;
|
||||
//
|
||||
// label4
|
||||
//
|
||||
this.label4.AutoSize = true;
|
||||
this.label4.Location = new System.Drawing.Point(12, 471);
|
||||
this.label4.Name = "label4";
|
||||
this.label4.Size = new System.Drawing.Size(52, 13);
|
||||
this.label4.TabIndex = 23;
|
||||
this.label4.Text = "Free Sale";
|
||||
//
|
||||
// dgvSale
|
||||
//
|
||||
this.dgvSale.AllowUserToAddRows = false;
|
||||
@@ -127,11 +108,9 @@
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(548, 519);
|
||||
this.ClientSize = new System.Drawing.Size(548, 478);
|
||||
this.Controls.Add(this.btnCopy);
|
||||
this.Controls.Add(this.btnPrint);
|
||||
this.Controls.Add(this.txtFreeSale);
|
||||
this.Controls.Add(this.label4);
|
||||
this.Controls.Add(this.dgvSale);
|
||||
this.Controls.Add(this.dtpFinish);
|
||||
this.Controls.Add(this.dtpStart);
|
||||
@@ -149,8 +128,6 @@
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.TextBox txtFreeSale;
|
||||
private System.Windows.Forms.Label label4;
|
||||
private System.Windows.Forms.DataGridView dgvSale;
|
||||
private System.Windows.Forms.DateTimePicker dtpFinish;
|
||||
private System.Windows.Forms.DateTimePicker dtpStart;
|
||||
|
||||
+254
-295
File diff suppressed because it is too large.
Load diff
@@ -29,7 +29,7 @@ namespace Tanshu.Accounts.PointOfSale
|
||||
private CustomerBO customer = new CustomerBI().GetCustomer(new Guid("F016CBAD-206C-42C0-BB1D-6006CE57BAB5"));
|
||||
private Guid? _advanceID;
|
||||
#endregion
|
||||
private SaleVoucherBO _billInfo;
|
||||
private VoucherBO _billInfo;
|
||||
object lockObject = new object();
|
||||
Guid? _newBillID;
|
||||
|
||||
@@ -80,7 +80,7 @@ namespace Tanshu.Accounts.PointOfSale
|
||||
}
|
||||
case Keys.F7:
|
||||
{
|
||||
using (SelectProduct selectProduct = new SelectProduct(new ProductBI().GetFilteredProducts, true))
|
||||
using (SelectProduct selectProduct = new SelectProduct(new FiltersBI().GetFilteredProducts, true))
|
||||
{
|
||||
selectProduct.ShowDialog();
|
||||
if (selectProduct.SelectedItem != null)
|
||||
@@ -273,18 +273,18 @@ namespace Tanshu.Accounts.PointOfSale
|
||||
private void btnPrintBill_Click(object sender, EventArgs e)
|
||||
{
|
||||
var val = Save(true);
|
||||
if (!val.HasValue)
|
||||
if (val == null)
|
||||
return;
|
||||
PrintBill(val.Value);
|
||||
ClearBill();
|
||||
PrintBill(val.VoucherID);
|
||||
ClearBill();
|
||||
}
|
||||
private void btnPrintKot_Click(object sender, EventArgs e)
|
||||
{
|
||||
var val = Save(false);
|
||||
if (!val.HasValue)
|
||||
if (val == null)
|
||||
return;
|
||||
PrintKOT(val.Value);
|
||||
ClearBill();
|
||||
PrintKOT(val.VoucherID);
|
||||
ClearBill();
|
||||
}
|
||||
private void btnCancel_Click(object sender, EventArgs e)
|
||||
{
|
||||
@@ -324,7 +324,17 @@ namespace Tanshu.Accounts.PointOfSale
|
||||
LoadBill(_newBillID.Value);
|
||||
ChangeFormState(SaleFormState.Billing);
|
||||
}
|
||||
ControlFactory.GenerateButtons(ref pnlBilling, new Rectangle(489, 94, 481, 385), 6, 6, 2, new ProductBI().GetUnFilteredProducts(), new ButtonClickDelegate(button_Click));
|
||||
using (var connection = new SqlDAO.SqlConnectionDAO())
|
||||
{
|
||||
using (var dao = new SqlDAO.ProductDAO(connection))
|
||||
{
|
||||
Dictionary<string, string> filter = new Dictionary<string, string>();
|
||||
filter.Add("Name", "");
|
||||
filter.Add("ProductGroup", "");
|
||||
var buttons = dao.GetFilteredProducts(filter);
|
||||
ControlFactory.GenerateButtons(ref pnlBilling, new Rectangle(489, 94, 481, 385), 6, 6, 2, buttons, new ButtonClickDelegate(button_Click));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void ChangeFormState(SaleFormState state)
|
||||
@@ -345,17 +355,21 @@ namespace Tanshu.Accounts.PointOfSale
|
||||
|
||||
#region Save Bill
|
||||
|
||||
private Guid? Save(bool finalBill)
|
||||
private VoucherBO Save(bool finalBill)
|
||||
{
|
||||
decimal? amount = null;
|
||||
if (_billInfo != null && new SaleVoucherBI().IsBillPrinted(_billInfo.VoucherID))
|
||||
VoucherBO oldVoucher = null;
|
||||
if (_billInfo != null)
|
||||
oldVoucher = new VoucherBI().GetVoucher(_billInfo.VoucherID);
|
||||
|
||||
if (oldVoucher != null && oldVoucher.Printed)
|
||||
{
|
||||
if (!Thread.CurrentPrincipal.IsInRole("Sales/EditBill"))
|
||||
{
|
||||
MessageBox.Show("You are not authorized to access");
|
||||
return null;
|
||||
}
|
||||
amount = new SaleVoucherBI().Amount(_billInfo.VoucherID);
|
||||
amount = oldVoucher.Amount;
|
||||
}
|
||||
if (bill.Count == 0)
|
||||
return null;
|
||||
@@ -364,7 +378,15 @@ namespace Tanshu.Accounts.PointOfSale
|
||||
if (_advanceID.HasValue)
|
||||
{
|
||||
var billAmount = Math.Round(bill.Values.Sum(b => b.Value));
|
||||
var advanceAmount = new AdvanceBI().Get(_advanceID.Value).Amount;
|
||||
decimal advanceAmount = 0;
|
||||
using (var connection = new SqlDAO.SqlConnectionDAO())
|
||||
{
|
||||
using (var dao = new SqlDAO.AdvanceDAO(connection))
|
||||
{
|
||||
advanceAmount = dao.Get(_advanceID.Value).Amount;
|
||||
}
|
||||
}
|
||||
|
||||
if (advanceAmount > billAmount)
|
||||
{
|
||||
if (MessageBox.Show("Advance adjusted amount more than bill amount, advance will not be adjusted.\n\rContinue will bill print?", "Advace adjustment error",
|
||||
@@ -375,10 +397,8 @@ namespace Tanshu.Accounts.PointOfSale
|
||||
}
|
||||
}
|
||||
var saved = _billInfo == null ? AddNewSale(finalBill) : UpdateSale(finalBill);
|
||||
if (saved.HasValue && _advanceID.HasValue)
|
||||
new AdvanceBI().Adjust(_advanceID.Value, CurrentUser.user.UserID);
|
||||
if (amount != null)
|
||||
Log.Warn(string.Format("{4} modified bill no {0}/{1} from (Rs. {2:#,00}) to (Rs. {3:#,00})", _billInfo.BillID, _billInfo.TableID, amount.Value, new SaleVoucherBI().Amount(saved.Value), Thread.CurrentPrincipal.Identity.Name));
|
||||
Log.Warn(string.Format("{4} modified bill no {0}/{1} from (Rs. {2:#,00}) to (Rs. {3:#,00})", _billInfo.BillID, _billInfo.TableID, amount.Value, saved.Amount, Thread.CurrentPrincipal.Identity.Name));
|
||||
if (_newBillID.HasValue)
|
||||
this.Close();
|
||||
return saved;
|
||||
@@ -400,8 +420,7 @@ namespace Tanshu.Accounts.PointOfSale
|
||||
else
|
||||
Print.Thermal.PrintWaiterKot("KOT", voucherID, bill.Values.ToList());
|
||||
}
|
||||
#region Save / Update
|
||||
private Guid? AddNewSale(bool finalBill)
|
||||
private VoucherBO AddNewSale(bool finalBill)
|
||||
{
|
||||
if (_billInfo != null)
|
||||
{
|
||||
@@ -412,13 +431,11 @@ namespace Tanshu.Accounts.PointOfSale
|
||||
if (btnWaiter.Tag == null)
|
||||
btnWaiter.Tag = new WaiterBI().GetWaiters()[0].WaiterID;
|
||||
|
||||
#region SaleVoucher
|
||||
var user = CurrentUser.user;
|
||||
var saleVoucher = new SaleVoucherBO
|
||||
var voucher = new VoucherBO
|
||||
{
|
||||
CustomerID = customer.CustomerID,
|
||||
PaidStatus = PaidStatus.Pending,
|
||||
//Paid = finalBill,
|
||||
TableID = txtTableID.Text,
|
||||
WaiterID = (Guid)btnWaiter.Tag,
|
||||
Printed = finalBill,
|
||||
@@ -428,33 +445,23 @@ namespace Tanshu.Accounts.PointOfSale
|
||||
Floor = _floor,
|
||||
AdvanceID = _advanceID
|
||||
};
|
||||
#endregion
|
||||
#region Inventories
|
||||
List<InventoryBO> iList = new SaleVoucherBI().SaleInventory(bill.Values, null);
|
||||
#endregion
|
||||
new SaleVoucherBI().Insert(saleVoucher, iList);
|
||||
return saleVoucher.VoucherID;
|
||||
|
||||
voucher.Inventories = new VoucherBI().SaleInventory(bill.Values, null);
|
||||
return new VoucherBI().Insert(voucher);
|
||||
}
|
||||
private Guid? UpdateSale(bool finalBill)
|
||||
private VoucherBO UpdateSale(bool finalBill)
|
||||
{
|
||||
if (btnWaiter.Tag == null)
|
||||
btnWaiter.Tag = new WaiterBI().GetWaiters()[0].WaiterID;
|
||||
|
||||
var user = CurrentUser.user;
|
||||
#region Voucher and SaleVoucher
|
||||
var saleVoucher = new SaleVoucherBO
|
||||
var voucher = new VoucherBO
|
||||
{
|
||||
VoucherID = _billInfo.VoucherID,
|
||||
UserID = _billInfo.UserID,
|
||||
Date = _billInfo.Date,
|
||||
CreationDate = DateTime.Now,
|
||||
LastEditDate = DateTime.Now,
|
||||
Narration = _billInfo.Narration,
|
||||
Alarm = _billInfo.Alarm,
|
||||
BillID = _billInfo.BillID,
|
||||
CustomerID = customer.CustomerID,
|
||||
KotID = _billInfo.KotID,
|
||||
PaidStatus = _billInfo.PaidStatus,
|
||||
Printed = _billInfo.Printed || finalBill,
|
||||
TableID = txtTableID.Text,
|
||||
@@ -464,16 +471,11 @@ namespace Tanshu.Accounts.PointOfSale
|
||||
AdvanceID = _advanceID
|
||||
};
|
||||
if ((!_billInfo.Printed) && finalBill)
|
||||
saleVoucher.Date = null;
|
||||
#endregion
|
||||
#region Inventory
|
||||
List<InventoryBO> iList = new SaleVoucherBI().SaleInventory(bill.Values, _billInfo.VoucherID);
|
||||
#endregion
|
||||
new SaleVoucherBI().Update(saleVoucher, iList);
|
||||
return saleVoucher.VoucherID;
|
||||
voucher.Date = null;
|
||||
voucher.Inventories = new VoucherBI().SaleInventory(bill.Values, _billInfo.VoucherID);
|
||||
return new VoucherBI().Update(voucher);
|
||||
}
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
|
||||
private void LoadBillFromTable()
|
||||
@@ -484,7 +486,7 @@ namespace Tanshu.Accounts.PointOfSale
|
||||
txtTableID.Text = result.Text.Trim();
|
||||
if ((txtTableID.Text != "C") && (txtTableID.Text != "") && (!txtTableID.Text.Contains(".")))
|
||||
{
|
||||
Guid? tID = new SaleVoucherBI().GetPendingVoucherID(txtTableID.Text, _floor);
|
||||
Guid? tID = new VoucherBI().GetPendingVoucherID(txtTableID.Text, _floor);
|
||||
if (tID.HasValue)
|
||||
{
|
||||
LoadBill(tID.Value);
|
||||
@@ -499,8 +501,7 @@ namespace Tanshu.Accounts.PointOfSale
|
||||
private void LoadBill(Guid voucherID)
|
||||
{
|
||||
ClearBill();
|
||||
var iList = new List<InventoryDisplayBO>();
|
||||
new SaleVoucherBI().GetSaleVoucher(voucherID, ref _billInfo, ref iList);
|
||||
_billInfo = new VoucherBI().GetVoucher(voucherID);
|
||||
|
||||
this.txtBillID.Text = _billInfo.BillID;
|
||||
this.txtKotID.Text = _billInfo.KotID;
|
||||
@@ -508,15 +509,15 @@ namespace Tanshu.Accounts.PointOfSale
|
||||
this.txtDate.Text = _billInfo.Date.Value.ToString("HH:mm dd-MMM-yyyy");
|
||||
this.txtLastEditDate.Text = _billInfo.LastEditDate.ToString("HH:mm dd-MMM-yyyy");
|
||||
this.txtNarration.Text = _billInfo.Narration;
|
||||
this.txtUserID.Text = new UserBI().GetUser(_billInfo.UserID).Name;
|
||||
this.customer = new CustomerBI().GetCustomer(_billInfo.CustomerID);
|
||||
this.txtUserID.Text = _billInfo.User.Name;
|
||||
this.customer = _billInfo.Customer;
|
||||
this.btnCustomer.Text = this.customer.Name;
|
||||
this.txtTableID.Text = _billInfo.TableID;
|
||||
this.btnWaiter.Tag = _billInfo.WaiterID;
|
||||
this._advanceID = _billInfo.AdvanceID;
|
||||
this.btnWaiter.Text = string.Format("{0} - F5", new WaiterBI().GetWaiter(_billInfo.WaiterID).Name);
|
||||
this.btnWaiter.Text = string.Format("{0} - F5", _billInfo.Waiter.Name);
|
||||
|
||||
foreach (var inventory in iList)
|
||||
foreach (var inventory in _billInfo.Inventories)
|
||||
{
|
||||
var key = new BillItemKey(inventory.ProductID, inventory.Quantity == 0);
|
||||
bill.Add(key, new SalesBillItemBO
|
||||
@@ -561,9 +562,9 @@ namespace Tanshu.Accounts.PointOfSale
|
||||
{
|
||||
lock (lockObject)
|
||||
{
|
||||
pendingBills = new SaleVoucherBI().GetPendingBills(pendingList, _floor);
|
||||
pendingBills = new VoucherBI().GetPendingBills(pendingList, _floor);
|
||||
bsPending.DataSource = pendingBills;
|
||||
var alarmBills = new SaleVoucherBI().GetPendingBills(PendingType.Alarms, _floor).OrderBy(b => b.AlarmTime).ToList();
|
||||
var alarmBills = new VoucherBI().GetPendingBills(PendingType.Alarms, _floor).OrderBy(b => b.AlarmTime).ToList();
|
||||
if (alarmBills.Count > 0)
|
||||
{
|
||||
var al = alarmBills.First();
|
||||
@@ -639,7 +640,7 @@ namespace Tanshu.Accounts.PointOfSale
|
||||
{
|
||||
if ((customer.CustomerID == new Guid("F016CBAD-206C-42C0-BB1D-6006CE57BAB5")) && (!reset))
|
||||
{
|
||||
using (SelectCustomer selectCustomer = new SelectCustomer(new CustomerBI().GetFilteredCustomers, true))
|
||||
using (SelectCustomer selectCustomer = new SelectCustomer(new FiltersBI().GetFilteredCustomers, true))
|
||||
{
|
||||
selectCustomer.customerEvent += new CustomerEventHandler(selectCustomer_customerEvent);
|
||||
selectCustomer.ShowDialog();
|
||||
@@ -707,7 +708,7 @@ namespace Tanshu.Accounts.PointOfSale
|
||||
voidReason.ShowDialog();
|
||||
if (voidReason.SelectedItem != null)
|
||||
{
|
||||
new SaleVoucherBI().VoidBill(_billInfo.VoucherID, voidReason.SelectedItem.Description, CurrentUser.user.UserID);
|
||||
new VoucherBI().VoidBill(_billInfo.VoucherID, voidReason.SelectedItem.Description, CurrentUser.user.UserID);
|
||||
ClearBill();
|
||||
}
|
||||
else
|
||||
@@ -761,14 +762,14 @@ namespace Tanshu.Accounts.PointOfSale
|
||||
private void btnPaidCash_Click(object sender, EventArgs e)
|
||||
{
|
||||
var user = CurrentUser.user;
|
||||
new SaleVoucherBI().DeclareBillsPaid(user.UserID, selectedBills, PaidStatus.Cash);
|
||||
new VoucherBI().DeclareBillsPaid(user.UserID, selectedBills, PaidStatus.Cash);
|
||||
ListUnpaidBills();
|
||||
}
|
||||
|
||||
private void btnPaidCC_Click(object sender, EventArgs e)
|
||||
{
|
||||
var user = CurrentUser.user;
|
||||
new SaleVoucherBI().DeclareBillsPaid(user.UserID, selectedBills, PaidStatus.CreditCard);
|
||||
new VoucherBI().DeclareBillsPaid(user.UserID, selectedBills, PaidStatus.CreditCard);
|
||||
ListUnpaidBills();
|
||||
}
|
||||
|
||||
@@ -787,12 +788,12 @@ namespace Tanshu.Accounts.PointOfSale
|
||||
DateTime alarmTime;
|
||||
if (result.Text == string.Empty)
|
||||
{
|
||||
new SaleVoucherBI().SetAlarm(billAlarm.voucherID, null);
|
||||
new VoucherBI().SetAlarm(billAlarm.voucherID, null);
|
||||
MessageBox.Show("Alarm Cleared", "Alarm Cleared", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
}
|
||||
else if (DateTime.TryParseExact(result.Text, "dd-MMM-yyyy HH:mm", new CultureInfo("en-US"), DateTimeStyles.None, out alarmTime))
|
||||
{
|
||||
new SaleVoucherBI().SetAlarm(billAlarm.voucherID, alarmTime);
|
||||
new VoucherBI().SetAlarm(billAlarm.voucherID, alarmTime);
|
||||
MessageBox.Show("Alarm set", "Alarm Set", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
}
|
||||
else
|
||||
@@ -811,16 +812,14 @@ namespace Tanshu.Accounts.PointOfSale
|
||||
var result = InputBox.Show("Bill No", "Bill No", "", InputBox_Validating);
|
||||
if (result.OK)
|
||||
{
|
||||
var saleVoucher = new SaleVoucherBO();
|
||||
var list = new List<InventoryDisplayBO>();
|
||||
new SaleVoucherBI().GetSaleVoucher(result.Text,ref saleVoucher, ref list);
|
||||
if (saleVoucher == null)
|
||||
var voucher = new VoucherBI().GetVoucher(result.Text);
|
||||
if (voucher == null)
|
||||
return;
|
||||
LoadBill(saleVoucher.VoucherID);
|
||||
LoadBill(voucher.VoucherID);
|
||||
ChangeFormState(SaleFormState.Billing);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//#region Filters
|
||||
//decimal? minValue = 0, maxValue = 0;
|
||||
@@ -937,14 +936,14 @@ namespace Tanshu.Accounts.PointOfSale
|
||||
private void btnPaidStaff_Click(object sender, EventArgs e)
|
||||
{
|
||||
var user = CurrentUser.user;
|
||||
new SaleVoucherBI().DeclareBillsPaid(user.UserID, selectedBills, PaidStatus.Staff);
|
||||
new VoucherBI().DeclareBillsPaid(user.UserID, selectedBills, PaidStatus.Staff);
|
||||
ListUnpaidBills();
|
||||
}
|
||||
|
||||
private void btnPaidCredit_Click(object sender, EventArgs e)
|
||||
{
|
||||
var user = CurrentUser.user;
|
||||
new SaleVoucherBI().DeclareBillsPaid(user.UserID, selectedBills, PaidStatus.Credit);
|
||||
new VoucherBI().DeclareBillsPaid(user.UserID, selectedBills, PaidStatus.Credit);
|
||||
ListUnpaidBills();
|
||||
}
|
||||
|
||||
@@ -959,6 +958,13 @@ namespace Tanshu.Accounts.PointOfSale
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void btnPaidNc_Click(object sender, EventArgs e)
|
||||
{
|
||||
var user = CurrentUser.user;
|
||||
new VoucherBI().DeclareBillsPaid(user.UserID, selectedBills, PaidStatus.Nc);
|
||||
ListUnpaidBills();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -129,27 +129,27 @@
|
||||
<metadata name="Display.UserAddedColumn" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
<metadata name="selectDataGridViewCheckBoxColumn.UserAddedColumn" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
<metadata name="TableID.UserAddedColumn" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
<metadata name="bsPending.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>248, 17</value>
|
||||
</metadata>
|
||||
<metadata name="selectDataGridViewCheckBoxColumn.UserAddedColumn" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
<metadata name="TableID.UserAddedColumn" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
<metadata name="bsPending.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>248, 17</value>
|
||||
</metadata>
|
||||
<metadata name="bindingSource.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>17, 17</value>
|
||||
</metadata>
|
||||
<metadata name="selectDataGridViewCheckBoxColumn.UserAddedColumn" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
<metadata name="TableID.UserAddedColumn" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
<metadata name="bsPending.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>248, 17</value>
|
||||
</metadata>
|
||||
<metadata name="selectDataGridViewCheckBoxColumn.UserAddedColumn" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
<metadata name="TableID.UserAddedColumn" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
<metadata name="bsPending.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>248, 17</value>
|
||||
</metadata>
|
||||
<metadata name="bsWaiter.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>148, 17</value>
|
||||
</metadata>
|
||||
|
||||
@@ -332,6 +332,10 @@
|
||||
<Project>{90C9D02C-91AF-4529-86BE-28320332DDB5}</Project>
|
||||
<Name>Tanshu.Accounts.Print</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\Tanshu.Accounts.SqlDAO\Tanshu.Accounts.SqlDAO.csproj">
|
||||
<Project>{B755D152-37C3-47D6-A721-3AD17A8EF316}</Project>
|
||||
<Name>Tanshu.Accounts.SqlDAO</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
|
||||
@@ -32,8 +32,8 @@ namespace Tanshu.Accounts.PointOfSale
|
||||
DateTime startDate = Convert.ToDateTime(String.Format("{0:dd-MMM-yyyy} 00:00:00", dtpStart.Value));
|
||||
DateTime finishDate = Convert.ToDateTime(String.Format("{0:dd-MMM-yyyy} 23:59:59", dtpFinish.Value));
|
||||
|
||||
decimal freeSale = 0, voids = 0, pending = 0, net = 0, tax = 0;
|
||||
det = new SalesAnalysisBI().GetSalesTaxReturn(startDate, finishDate, ref freeSale, ref voids, ref pending, ref net, ref tax);
|
||||
decimal voids = 0, pending = 0, net = 0, vat = 0, serviceTax = 0, nc = 0;
|
||||
det = new SalesAnalysisBI().GetSalesTaxReturn(startDate, finishDate, ref voids, ref pending, ref net, ref vat, ref serviceTax, ref nc);
|
||||
|
||||
//dc.CommandTimeout = 50000;
|
||||
dgvSale.AutoGenerateColumns = true;
|
||||
@@ -49,8 +49,8 @@ namespace Tanshu.Accounts.PointOfSale
|
||||
txtVoid.Text = String.Format("{0:#,##0.00;(#,##0.00);0}", voids);
|
||||
txtPending.Text = String.Format("{0:#,##0.00;(#,##0.00);0}", pending);
|
||||
txtNet.Text = String.Format("{0:#,##0.00;(#,##0.00);0}", net);
|
||||
txtTax.Text = String.Format("{0:#,##0.00;(#,##0.00);0}", tax);
|
||||
txtGross.Text = String.Format("{0:#,##0.00;(#,##0.00);0}", net + tax);
|
||||
txtVat.Text = String.Format("{0:#,##0.00;(#,##0.00);0}", vat);
|
||||
txtServiceTax.Text = String.Format("{0:#,##0.00;(#,##0.00);0}", net + serviceTax);
|
||||
}
|
||||
|
||||
private void dtpFinish_ValueChanged(object sender, EventArgs e)
|
||||
|
||||
+24
-24
@@ -29,8 +29,8 @@
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.txtNet = new System.Windows.Forms.TextBox();
|
||||
this.txtTax = new System.Windows.Forms.TextBox();
|
||||
this.txtGross = new System.Windows.Forms.TextBox();
|
||||
this.txtVat = new System.Windows.Forms.TextBox();
|
||||
this.txtServiceTax = new System.Windows.Forms.TextBox();
|
||||
this.txtPending = new System.Windows.Forms.TextBox();
|
||||
this.txtVoid = new System.Windows.Forms.TextBox();
|
||||
this.label5 = new System.Windows.Forms.Label();
|
||||
@@ -54,21 +54,21 @@
|
||||
this.txtNet.Size = new System.Drawing.Size(100, 20);
|
||||
this.txtNet.TabIndex = 17;
|
||||
//
|
||||
// txtTax
|
||||
// txtVat
|
||||
//
|
||||
this.txtTax.Location = new System.Drawing.Point(330, 487);
|
||||
this.txtTax.Name = "txtTax";
|
||||
this.txtTax.ReadOnly = true;
|
||||
this.txtTax.Size = new System.Drawing.Size(100, 20);
|
||||
this.txtTax.TabIndex = 18;
|
||||
this.txtVat.Location = new System.Drawing.Point(330, 487);
|
||||
this.txtVat.Name = "txtVat";
|
||||
this.txtVat.ReadOnly = true;
|
||||
this.txtVat.Size = new System.Drawing.Size(100, 20);
|
||||
this.txtVat.TabIndex = 18;
|
||||
//
|
||||
// txtGross
|
||||
// txtServiceTax
|
||||
//
|
||||
this.txtGross.Location = new System.Drawing.Point(436, 487);
|
||||
this.txtGross.Name = "txtGross";
|
||||
this.txtGross.ReadOnly = true;
|
||||
this.txtGross.Size = new System.Drawing.Size(100, 20);
|
||||
this.txtGross.TabIndex = 19;
|
||||
this.txtServiceTax.Location = new System.Drawing.Point(436, 487);
|
||||
this.txtServiceTax.Name = "txtServiceTax";
|
||||
this.txtServiceTax.ReadOnly = true;
|
||||
this.txtServiceTax.Size = new System.Drawing.Size(100, 20);
|
||||
this.txtServiceTax.TabIndex = 19;
|
||||
//
|
||||
// txtPending
|
||||
//
|
||||
@@ -109,18 +109,18 @@
|
||||
this.label3.AutoSize = true;
|
||||
this.label3.Location = new System.Drawing.Point(327, 471);
|
||||
this.label3.Name = "label3";
|
||||
this.label3.Size = new System.Drawing.Size(25, 13);
|
||||
this.label3.Size = new System.Drawing.Size(23, 13);
|
||||
this.label3.TabIndex = 26;
|
||||
this.label3.Text = "Tax";
|
||||
this.label3.Text = "Vat";
|
||||
//
|
||||
// label2
|
||||
//
|
||||
this.label2.AutoSize = true;
|
||||
this.label2.Location = new System.Drawing.Point(433, 471);
|
||||
this.label2.Name = "label2";
|
||||
this.label2.Size = new System.Drawing.Size(58, 13);
|
||||
this.label2.Size = new System.Drawing.Size(64, 13);
|
||||
this.label2.TabIndex = 27;
|
||||
this.label2.Text = "Gross Sale";
|
||||
this.label2.Text = "Service Tax";
|
||||
//
|
||||
// label1
|
||||
//
|
||||
@@ -187,15 +187,15 @@
|
||||
this.btnPrint.UseVisualStyleBackColor = true;
|
||||
this.btnPrint.Click += new System.EventHandler(this.btnPrint_Click);
|
||||
//
|
||||
// frmSaleAnalysisForm
|
||||
// SaleTaxReportForm
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(548, 519);
|
||||
this.Controls.Add(this.btnPrint);
|
||||
this.Controls.Add(this.txtNet);
|
||||
this.Controls.Add(this.txtTax);
|
||||
this.Controls.Add(this.txtGross);
|
||||
this.Controls.Add(this.txtVat);
|
||||
this.Controls.Add(this.txtServiceTax);
|
||||
this.Controls.Add(this.txtPending);
|
||||
this.Controls.Add(this.txtVoid);
|
||||
this.Controls.Add(this.label5);
|
||||
@@ -208,7 +208,7 @@
|
||||
this.Controls.Add(this.dtpStart);
|
||||
this.Controls.Add(this.label10);
|
||||
this.MaximizeBox = false;
|
||||
this.Name = "frmSaleAnalysisForm";
|
||||
this.Name = "SaleTaxReportForm";
|
||||
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
|
||||
this.Text = "Sale Analysis Form";
|
||||
this.Load += new System.EventHandler(this.Sale_Analysis_Form_Load);
|
||||
@@ -221,8 +221,8 @@
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.TextBox txtNet;
|
||||
private System.Windows.Forms.TextBox txtTax;
|
||||
private System.Windows.Forms.TextBox txtGross;
|
||||
private System.Windows.Forms.TextBox txtVat;
|
||||
private System.Windows.Forms.TextBox txtServiceTax;
|
||||
private System.Windows.Forms.TextBox txtPending;
|
||||
private System.Windows.Forms.TextBox txtVoid;
|
||||
private System.Windows.Forms.Label label5;
|
||||
|
||||
@@ -21,62 +21,51 @@ namespace Tanshu.Accounts.Print
|
||||
private static readonly bool IsTwenty = System.Configuration.ConfigurationManager.AppSettings["Twenty"].Trim().ToLowerInvariant() == "true";
|
||||
private const string DrawLine = "\n\r------------------------------------------";
|
||||
private const string DrawEqual = "\n\r==========================================";
|
||||
private static string DesignKot(SaleVoucherBO trans, IEnumerable<SalesBillItemBO> billItems, string title)
|
||||
private static string DesignKot(VoucherBO voucher, IEnumerable<SalesBillItemBO> billItems, string title)
|
||||
{
|
||||
var waiter = new WaiterBI().GetWaiter(trans.WaiterID);
|
||||
try
|
||||
var billText = title;
|
||||
billText += title;
|
||||
billText += DrawLine;
|
||||
billText += string.Format("\n\rKOT ID : {0,-13} {1:dd-MMM-yyyy HH:mm}", voucher.KotID, voucher.Date);
|
||||
billText += string.Format("\n\rTable No.: {0} / {1}", voucher.TableID, voucher.Waiter.Name);
|
||||
billText += DrawLine;
|
||||
billText += "\n\r Qty. x Name ";
|
||||
billText += DrawLine;
|
||||
foreach (var item in billItems)
|
||||
{
|
||||
var billText = title;
|
||||
billText += title;
|
||||
billText += DrawLine;
|
||||
billText += string.Format("\n\rKOT ID : {0,-13} {1:dd-MMM-yyyy HH:mm}", trans.KotID, trans.Date);
|
||||
billText += string.Format("\n\rTable No.: {0} / {1}", trans.TableID, waiter.Name);
|
||||
billText += DrawLine;
|
||||
billText += "\n\r Qty. x Name ";
|
||||
billText += DrawLine;
|
||||
foreach (var item in billItems)
|
||||
var additional = item.Quantity - item.Printed;
|
||||
if (additional > 0)
|
||||
{
|
||||
var additional = item.Quantity - item.Printed;
|
||||
if (additional > 0)
|
||||
{
|
||||
billText += string.Format("\n\r{0,6} x {1,-27} @ {2,6}", additional, item.Name, item.Price);
|
||||
}
|
||||
billText += string.Format("\n\r{0,6} x {1,-27} @ {2,6}", additional, item.Name, item.Price);
|
||||
}
|
||||
billText += DrawLine;
|
||||
if (trans.Narration != "")
|
||||
{
|
||||
billText += "\n\r" + FormatText(trans.Narration, 42, false, Align.Centre);
|
||||
billText += DrawLine;
|
||||
}
|
||||
billText += CutPrinter;
|
||||
return billText;
|
||||
}
|
||||
catch (Exception ex)
|
||||
billText += DrawLine;
|
||||
if (voucher.Narration != "")
|
||||
{
|
||||
throw ex;
|
||||
billText += "\n\r" + FormatText(voucher.Narration, 42, false, Align.Centre);
|
||||
billText += DrawLine;
|
||||
}
|
||||
billText += CutPrinter;
|
||||
return billText;
|
||||
}
|
||||
private static string DesignWaiterKot(SaleVoucherBO trans, IEnumerable<SalesBillItemBO> billItems)
|
||||
private static string DesignWaiterKot(VoucherBO voucher, IEnumerable<SalesBillItemBO> billItems)
|
||||
{
|
||||
return DesignKot(trans, billItems, string.Format("\n\rWAITER WAITER WAITER WAITER WAITER\n\rWAITER WAITER WAITER WAITER WAITER"));
|
||||
return DesignKot(voucher, billItems, string.Format("\n\rWAITER WAITER WAITER WAITER WAITER\n\rWAITER WAITER WAITER WAITER WAITER"));
|
||||
}
|
||||
private static string DesignPickupKot(SaleVoucherBO trans, IEnumerable<SalesBillItemBO> billItems)
|
||||
private static string DesignPickupKot(VoucherBO voucher, IEnumerable<SalesBillItemBO> billItems)
|
||||
{
|
||||
return DesignKot(trans, billItems, string.Format("\n\rPICK-UP PICK-UP PICK-UP PICK-UP PICK-UP\n\rPICK-UP PICK-UP PICK-UP PICK-UP PICK-UP"));
|
||||
return DesignKot(voucher, billItems, string.Format("\n\rPICK-UP PICK-UP PICK-UP PICK-UP PICK-UP\n\rPICK-UP PICK-UP PICK-UP PICK-UP PICK-UP"));
|
||||
}
|
||||
private static string DesignCustomerKot(SaleVoucherBO trans, IEnumerable<SalesBillItemBO> billItems)
|
||||
private static string DesignCustomerKot(VoucherBO voucher, IEnumerable<SalesBillItemBO> billItems)
|
||||
{
|
||||
return DesignKot(trans, billItems, string.Format("\n\r Counter / Order Slip "));
|
||||
return DesignKot(voucher, billItems, string.Format("\n\r Counter / Order Slip "));
|
||||
}
|
||||
|
||||
private static string DesignBill(SaleVoucherBO trans, IEnumerable<InventoryDisplayBO> billItems)
|
||||
private static string DesignBill(VoucherBO voucher)
|
||||
{
|
||||
var cashier = new UserBI().GetUser(trans.UserID);
|
||||
var waiter = new WaiterBI().GetWaiter(trans.WaiterID);
|
||||
var customer = new CustomerBI().GetCustomer(trans.CustomerID);
|
||||
var billNo = trans.BillID.Substring(trans.BillID.IndexOf("-") + 1);
|
||||
var billNo = voucher.BillID.Substring(voucher.BillID.IndexOf("-") + 1);
|
||||
|
||||
var billText = "\n\r" + FormatText("Bengali Sweet House", 42, false, Align.Centre);
|
||||
var billText = "\n\r" + FormatText("Bengali Sweets", 42, false, Align.Centre);
|
||||
billText += "\n\r" + FormatText("+ V2C Multi Cuisine", 42, false, Align.Centre);
|
||||
if (!IsTwenty)
|
||||
billText += "\n\r" + FormatText("SCO 1, Pocket 1, Manimajra, Chandigarh", 42, false, Align.Centre);
|
||||
@@ -84,18 +73,26 @@ namespace Tanshu.Accounts.Print
|
||||
billText += "\n\r" + FormatText("SCO 399, Sector 20, Panchkula", 42, false, Align.Centre);
|
||||
|
||||
billText += "\n\r" + FormatText("A Unit of AA Herbal Biotech Pvt. Ltd.", 42, false, Align.Centre);
|
||||
billText += "\n\r" + FormatText("CIN: U24230CH2004PTC026903", 42, false, Align.Centre);
|
||||
billText += "\n\r" + FormatText("Reg Add:705, Indl. Area, Ph II, Chandigarh", 42, false, Align.Centre);
|
||||
if (!IsTwenty)
|
||||
{
|
||||
billText += "\n\r" + FormatText("TIN: 04400023630", 42, false, Align.Centre);
|
||||
billText += "\n\r" + FormatText("Service Tax: AAFCA1727JSD002", 42, false, Align.Centre);
|
||||
}
|
||||
else
|
||||
{
|
||||
billText += "\n\r" + FormatText("TIN: 06892504733", 42, false, Align.Centre);
|
||||
billText += "\n\r" + FormatText("Service Tax: AAFCA1727JSD003", 42, false, Align.Centre);
|
||||
}
|
||||
billText += "\n\r" + FormatText("Retail Invoice", 42, false, Align.Centre);
|
||||
billText += "\n\r";
|
||||
billText += "\n\r" + "Bill No: " + FormatText(billNo, 13, false, Align.Centre) + string.Format("{0:dd-MMM-yyyy HH:mm:ss}", trans.Date);
|
||||
billText += "\n\r" + "Table No.: " + trans.TableID;
|
||||
billText += "\n\r" + "Bill No: " + FormatText(billNo, 13, false, Align.Centre) + string.Format("{0:dd-MMM-yyyy HH:mm:ss}", voucher.Date);
|
||||
billText += "\n\r" + "Table No.: " + voucher.TableID;
|
||||
billText += "\n\r" + "------------------------------------------";
|
||||
billText += "\n\r" + "Qty. Particulars Price Amount";
|
||||
billText += "\n\r" + "------------------------------------------";
|
||||
foreach (var item in billItems)
|
||||
foreach (var item in voucher.Inventories)
|
||||
{
|
||||
if (Math.Round((item.Rate * (1 + item.Vat + item.ServiceTax)), 0) == 1)
|
||||
{
|
||||
@@ -114,41 +111,41 @@ namespace Tanshu.Accounts.Print
|
||||
}
|
||||
billText += "\n\r" + "------------------------------------------";
|
||||
|
||||
decimal amount = billItems.Sum(b => b.Vat * b.Quantity * b.Rate * (1 - b.Discount));
|
||||
decimal amount = voucher.Inventories.Sum(b => b.Vat * b.Quantity * b.Rate * (1 - b.Discount));
|
||||
if (amount != 0)
|
||||
billText += "\n\r" + FormatText("VAT : ", 33, false, Align.Right) + FormatBillNum(amount, 9);
|
||||
|
||||
amount = billItems.Sum(b => b.ServiceTax * b.Quantity * b.Rate * (1 - b.Discount));
|
||||
amount = voucher.Inventories.Sum(b => b.ServiceTax * b.Quantity * b.Rate * (1 - b.Discount));
|
||||
if (amount != 0)
|
||||
billText += "\n\r" + FormatText("Service Tax : ", 33, false, Align.Right) + FormatBillNum(amount, 9);
|
||||
|
||||
amount = billItems.Sum(b => b.Quantity * b.Rate * b.Discount);
|
||||
amount = voucher.Inventories.Sum(b => b.Quantity * b.Rate * b.Discount);
|
||||
if (amount != 0)
|
||||
billText += "\n\r" + FormatText("Discount : ", 33, false, Align.Right) + FormatBillNum(amount, 9);
|
||||
|
||||
decimal advance = 0;
|
||||
if (trans.AdvanceID.HasValue)
|
||||
if (voucher.AdvanceID.HasValue)
|
||||
{
|
||||
advance = new AdvanceBI().Get(trans.AdvanceID.Value).Amount;
|
||||
advance = voucher.Advance.Amount;
|
||||
billText += "\n\r" + FormatText("Less Advance : ", 33, false, Align.Right) + FormatBillNum(advance, 9);
|
||||
}
|
||||
|
||||
amount = billItems.Sum(b => b.Amount) - advance;
|
||||
amount = voucher.Inventories.Sum(b => b.Amount) - advance;
|
||||
|
||||
billText += string.Format("\n\r Final Amount : {0,9:#,##0.00;(#,##0.00);0}", Math.Round(amount, 0));
|
||||
billText += DrawLine;
|
||||
if (trans.Narration != "")
|
||||
if (voucher.Narration != "")
|
||||
{
|
||||
billText += "\n\r" + FormatText(trans.Narration, 42, false, Align.Centre);
|
||||
billText += "\n\r" + FormatText(voucher.Narration, 42, false, Align.Centre);
|
||||
billText += DrawLine;
|
||||
}
|
||||
if (customer.Name != "Cash")
|
||||
if (voucher.Customer.Name != "Cash")
|
||||
{
|
||||
billText += "\n\r" + customer.Name;
|
||||
billText += string.Format("\n\r{0}\n\r{1}", customer.Phone, customer.Address);
|
||||
billText += "\n\r" + voucher.Customer.Name;
|
||||
billText += string.Format("\n\r{0}\n\r{1}", voucher.Customer.Phone, voucher.Customer.Address);
|
||||
billText += DrawLine;
|
||||
}
|
||||
billText += "\n\r" + "Cashier : " + cashier.Name + " / " + waiter.Name;
|
||||
billText += "\n\r" + "Cashier : " + voucher.User.Name + " / " + voucher.Waiter.Name;
|
||||
if (!IsTwenty)
|
||||
billText += "\n\r" + " For Home Delivery: 0172-3242030, 3243040 ";
|
||||
else
|
||||
@@ -194,7 +191,7 @@ namespace Tanshu.Accounts.Print
|
||||
private static bool PrintRaw(string text, string documentName)
|
||||
{
|
||||
#if (DEBUG)
|
||||
MessageBox.Show(text,documentName);
|
||||
MessageBox.Show(text, documentName);
|
||||
return true;
|
||||
#else
|
||||
var printerName = System.Configuration.ConfigurationManager.AppSettings["Printer"].Trim();
|
||||
@@ -211,27 +208,19 @@ namespace Tanshu.Accounts.Print
|
||||
{
|
||||
string printText;
|
||||
int total = 0;
|
||||
try
|
||||
printText = FormatText(CurrentUser.user.Name, 42, false, Align.Centre);
|
||||
printText += DrawLine;
|
||||
printText += "\n\r" + FormatText(string.Format("{0:dd-MMM-yyyy HH:mm:ss}", DateTime.Now), 42, false, Align.Centre);
|
||||
foreach (int key in amount.Keys.OrderByDescending(k => k))
|
||||
{
|
||||
printText = FormatText(CurrentUser.user.Name, 42, false, Align.Centre);
|
||||
printText += DrawLine;
|
||||
printText += "\n\r" + FormatText(string.Format("{0:dd-MMM-yyyy HH:mm:ss}", DateTime.Now), 42, false, Align.Centre);
|
||||
foreach (int key in amount.Keys.OrderByDescending(k => k))
|
||||
{
|
||||
printText += CashLine(amount, key);
|
||||
total += amount[key] * key;
|
||||
}
|
||||
printText += "\n\r" + DrawEqual;
|
||||
printText += string.Format("\n\r Total = {0,10:#,##0}", total);
|
||||
printText += DrawLine;
|
||||
printText += CutPrinter;
|
||||
return PrintRaw(printText, "Closing/Opening for " + CurrentUser.user.Name);
|
||||
printText += CashLine(amount, key);
|
||||
total += amount[key] * key;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw;
|
||||
}
|
||||
|
||||
printText += "\n\r" + DrawEqual;
|
||||
printText += string.Format("\n\r Total = {0,10:#,##0}", total);
|
||||
printText += DrawLine;
|
||||
printText += CutPrinter;
|
||||
return PrintRaw(printText, "Closing/Opening for " + CurrentUser.user.Name);
|
||||
}
|
||||
public static Boolean PrintSale(List<SalesAnalysisBO> det, DateTime startDate, DateTime endDate)
|
||||
{
|
||||
@@ -330,6 +319,7 @@ namespace Tanshu.Accounts.Print
|
||||
billText += string.Format("\n\rCC Receipts : {0,26:#,##0.00}", details.CreditCardReceipts);
|
||||
billText += string.Format("\n\rCredit Sale : {0,26:#,##0.00}", details.CreditReceipts);
|
||||
billText += string.Format("\n\rStaff Sale : {0,26:#,##0.00}", details.StaffReceipts);
|
||||
billText += string.Format("\n\rNo Charge : {0,26:#,##0.00}", details.NcBills);
|
||||
billText += string.Format("\n\rAdvance Adj. : {0,26:#,##0.00}", details.AdvanceAdjusted);
|
||||
billText += string.Format("\n\rPayments : {0,26:#,##0.00}", details.CashPayments);
|
||||
billText += string.Format("\n\rAddl. Voids : {0,26:#,##0.00}", details.AdditionalVoids);
|
||||
@@ -362,6 +352,9 @@ namespace Tanshu.Accounts.Print
|
||||
if (details.VoidsString.Length > 0)
|
||||
billText += details.VoidsString;
|
||||
|
||||
if (details.NcString.Length > 0)
|
||||
billText += details.NcString;
|
||||
|
||||
if (details.PaymentString.Length > 0)
|
||||
billText += details.PaymentString;
|
||||
|
||||
@@ -380,31 +373,25 @@ namespace Tanshu.Accounts.Print
|
||||
|
||||
public static void PrintBill(Guid voucherID)
|
||||
{
|
||||
SaleVoucherBO trans = new SaleVoucherBO();
|
||||
List<InventoryDisplayBO> iList = new List<InventoryDisplayBO>();
|
||||
new SaleVoucherBI().GetSaleVoucher(voucherID, ref trans, ref iList);
|
||||
PrintRaw(DesignBill(trans, iList), "Bill");
|
||||
var voucher = new VoucherBI().GetVoucher(voucherID);
|
||||
PrintRaw(DesignBill(voucher), "Bill");
|
||||
}
|
||||
|
||||
public static void PrintWaiterKot(string p, Guid voucherID, List<SalesBillItemBO> list)
|
||||
{
|
||||
SaleVoucherBO trans = new SaleVoucherBO();
|
||||
List<InventoryDisplayBO> iList = new List<InventoryDisplayBO>();
|
||||
new SaleVoucherBI().GetSaleVoucher(voucherID, ref trans, ref iList);
|
||||
var voucher = new VoucherBI().GetVoucher(voucherID);
|
||||
if (list.Count(i => (i.Quantity - i.Printed) > 0) > 0)
|
||||
{
|
||||
PrintRaw(DesignWaiterKot(trans, list), "KOT");
|
||||
PrintRaw(DesignPickupKot(trans, list), "KOT");
|
||||
PrintRaw(DesignWaiterKot(voucher, list), "KOT");
|
||||
PrintRaw(DesignPickupKot(voucher, list), "KOT");
|
||||
}
|
||||
}
|
||||
public static void PrintCustomerKot(string p, Guid voucherID, List<SalesBillItemBO> list)
|
||||
{
|
||||
SaleVoucherBO trans = new SaleVoucherBO();
|
||||
List<InventoryDisplayBO> iList = new List<InventoryDisplayBO>();
|
||||
new SaleVoucherBI().GetSaleVoucher(voucherID, ref trans, ref iList);
|
||||
var voucher = new VoucherBI().GetVoucher(voucherID);
|
||||
if (list.Count(i => (i.Quantity - i.Printed) > 0) > 0)
|
||||
{
|
||||
PrintRaw(DesignCustomerKot(trans, list), "KOT");
|
||||
PrintRaw(DesignCustomerKot(voucher, list), "KOT");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -24,12 +24,12 @@ namespace Tanshu.Accounts.SqlDAO
|
||||
info = "";
|
||||
|
||||
const string query = @"
|
||||
SELECT t.Date, s.BillID, c.Name, t.LastEditDate, SUM(i.Amount) AS Amount, SUM(i.Quantity * i.Rate * i.Discount) AS Discount FROM Vouchers t INNER JOIN SaleVoucher s ON t.VoucherID = s.VoucherID
|
||||
INNER JOIN Inventory i ON t.VoucherID = i.VoucherID
|
||||
INNER JOIN Customers c ON s.CustomerID = c.CustomerID
|
||||
WHERE t.LastEditDate BETWEEN @StartDate AND @FinishDate AND t.UserID = @UserID
|
||||
AND s.PaidStatus = @PaidStatus
|
||||
GROUP BY t.Date, c.Name, s.BillID, t.LastEditDate
|
||||
SELECT v.Date, v.BillID, c.Name, v.LastEditDate, SUM(i.Amount) AS Amount, SUM(i.Quantity * i.Rate * i.Discount) AS Discount FROM Vouchers v
|
||||
INNER JOIN Inventory i ON v.VoucherID = i.VoucherID
|
||||
INNER JOIN Customers c ON v.CustomerID = c.CustomerID
|
||||
WHERE v.LastEditDate BETWEEN @StartDate AND @FinishDate AND v.UserID = @UserID
|
||||
AND v.PaidStatus = @PaidStatus
|
||||
GROUP BY v.Date, c.Name, v.BillID, v.LastEditDate
|
||||
";
|
||||
using (var cmd = new SqlCommand(query))
|
||||
{
|
||||
@@ -200,16 +200,17 @@ SELECT DISTINCT CashierOut FROM Advances WHERE DateOut BETWEEN @StartDate AND @F
|
||||
public decimal GetNetSales()
|
||||
{
|
||||
const string query = @"
|
||||
SELECT ISNULL(SUM(i.Amount), 0) AS Amount FROM Vouchers t INNER JOIN SaleVoucher s ON t.VoucherID = s.VoucherID
|
||||
INNER JOIN Inventory i ON t.VoucherID = i.VoucherID
|
||||
INNER JOIN Customers c ON s.CustomerID = c.CustomerID
|
||||
WHERE t.LastEditDate BETWEEN @StartDate AND @FinishDate AND t.UserID = @UserID
|
||||
AND s.PaidStatus != @Pending AND s.PaidStatus != @Void
|
||||
SELECT ISNULL(SUM(i.Amount), 0) AS Amount FROM Vouchers v
|
||||
INNER JOIN Inventory i ON v.VoucherID = i.VoucherID
|
||||
INNER JOIN Customers c ON v.CustomerID = c.CustomerID
|
||||
WHERE v.LastEditDate BETWEEN @StartDate AND @FinishDate AND v.UserID = @UserID
|
||||
AND v.PaidStatus NOT IN (@Pending, @Void, @Nc)
|
||||
";
|
||||
using (var cmd = new SqlCommand(query))
|
||||
{
|
||||
cmd.Parameters.AddWithValue("@Pending", (int)PaidStatus.Pending);
|
||||
cmd.Parameters.AddWithValue("@Void", (int)PaidStatus.Void);
|
||||
cmd.Parameters.AddWithValue("@Nc", (int)PaidStatus.Nc);
|
||||
cmd.Parameters.AddWithValue("@StartDate", _startDate);
|
||||
cmd.Parameters.AddWithValue("@FinishDate", _finishDate);
|
||||
cmd.Parameters.AddWithValue("@UserID", _userID);
|
||||
@@ -223,18 +224,16 @@ AND s.PaidStatus != @Pending AND s.PaidStatus != @Void
|
||||
info = "";
|
||||
|
||||
const string query = @"
|
||||
SELECT v.Date, s.BillID, c.Name, SUM(i.Amount) AS Amount, SUM(i.Quantity * i.Rate * i.Discount) AS Discount
|
||||
FROM Vouchers v INNER JOIN SaleVoucher s ON v.VoucherID = s.VoucherID
|
||||
INNER JOIN Inventory i ON v.VoucherID = i.VoucherID
|
||||
INNER JOIN Customers c ON s.CustomerID = c.CustomerID
|
||||
SELECT v.Date, v.BillID, c.Name, SUM(i.Amount) AS Amount, SUM(i.Quantity * i.Rate * i.Discount) AS Discount
|
||||
FROM Vouchers v INNER JOIN Inventory i ON v.VoucherID = i.VoucherID
|
||||
INNER JOIN Customers c ON v.CustomerID = c.CustomerID
|
||||
WHERE v.VoucherID IN (
|
||||
SELECT v.VoucherID FROM Vouchers v INNER JOIN SaleVoucher s ON v.VoucherID = s.VoucherID
|
||||
INNER JOIN Inventory i ON v.VoucherID = i.VoucherID
|
||||
SELECT v.VoucherID FROM Vouchers v INNER JOIN Inventory i ON v.VoucherID = i.VoucherID
|
||||
WHERE v.LastEditDate BETWEEN @StartDate AND @FinishDate AND v.UserID = @UserID
|
||||
AND s.PaidStatus != @Void
|
||||
AND v.PaidStatus != @Void
|
||||
AND i.Discount >= .05
|
||||
)
|
||||
GROUP BY v.Date, s.BillID, c.Name
|
||||
GROUP BY v.Date, v.BillID, c.Name
|
||||
";
|
||||
using (var cmd = new SqlCommand(query))
|
||||
{
|
||||
@@ -264,10 +263,10 @@ GROUP BY v.Date, s.BillID, c.Name
|
||||
public decimal GetOldPending()
|
||||
{
|
||||
const string query = @"
|
||||
SELECT ISNULL(SUM(i.Amount), 0) FROM Vouchers t INNER JOIN SaleVoucher s ON t.VoucherID = s.VoucherID
|
||||
INNER JOIN Inventory i ON t.VoucherID = i.VoucherID
|
||||
WHERE s.PaidStatus = @Pending
|
||||
AND t.LastEditDate < @StartDate AND t.UserID = @UserID
|
||||
SELECT ISNULL(SUM(i.Amount), 0) FROM Vouchers v
|
||||
INNER JOIN Inventory i ON v.VoucherID = i.VoucherID
|
||||
WHERE v.PaidStatus = @Pending
|
||||
AND v.LastEditDate < @StartDate AND v.UserID = @UserID
|
||||
";
|
||||
using (var cmd = new SqlCommand(query))
|
||||
{
|
||||
@@ -281,10 +280,10 @@ AND t.LastEditDate < @StartDate AND t.UserID = @UserID
|
||||
public decimal GetOldReceipts()
|
||||
{
|
||||
const string query = @"
|
||||
SELECT ISNULL(SUM(i.Amount), 0) FROM Vouchers t INNER JOIN SaleVoucher s ON t.VoucherID = s.VoucherID
|
||||
INNER JOIN Inventory i ON t.VoucherID = i.VoucherID
|
||||
WHERE s.PaidStatus != @Pending AND s.PaidStatus != @Void
|
||||
AND t.CreationDate < @StartDate AND t.LastEditDate >= @StartDate AND t.UserID = @UserID
|
||||
SELECT ISNULL(SUM(i.Amount), 0) FROM Vouchers v
|
||||
INNER JOIN Inventory i ON v.VoucherID = i.VoucherID
|
||||
WHERE v.PaidStatus != @Pending AND v.PaidStatus != @Void
|
||||
AND v.CreationDate < @StartDate AND v.LastEditDate >= @StartDate AND v.UserID = @UserID
|
||||
";
|
||||
using (var cmd = new SqlCommand(query))
|
||||
{
|
||||
@@ -299,10 +298,10 @@ AND t.CreationDate < @StartDate AND t.LastEditDate >= @StartDate AND t.UserID =
|
||||
public decimal GetOldVoided()
|
||||
{
|
||||
const string query = @"
|
||||
SELECT ISNULL(SUM(i.Amount), 0) FROM Vouchers t INNER JOIN SaleVoucher s ON t.VoucherID = s.VoucherID
|
||||
INNER JOIN Inventory i ON t.VoucherID = i.VoucherID
|
||||
WHERE s.PaidStatus = @Void
|
||||
AND t.CreationDate < @StartDate AND t.LastEditDate >= @StartDate AND t.UserID = @UserID
|
||||
SELECT ISNULL(SUM(i.Amount), 0) FROM Vouchers v
|
||||
INNER JOIN Inventory i ON v.VoucherID = i.VoucherID
|
||||
WHERE v.PaidStatus = @Void
|
||||
AND v.CreationDate < @StartDate AND v.LastEditDate >= @StartDate AND v.UserID = @UserID
|
||||
";
|
||||
using (var cmd = new SqlCommand(query))
|
||||
{
|
||||
|
||||
@@ -77,11 +77,11 @@ SELECT @Amount = Amount FROM Inventory WHERE InventoryID = @InventoryID;"))
|
||||
}
|
||||
}
|
||||
|
||||
public List<InventoryDisplayBO> GetInventories(Guid voucherID)
|
||||
public List<InventoryBO> GetInventories(Guid voucherID)
|
||||
{
|
||||
SqlCommand cmd = new SqlCommand("SELECT p.Name + ' (' + p.Units +')' AS ProductName, i.* FROM Inventory i INNER JOIN Products p ON i.ProductID = p.ProductID WHERE VoucherID = @VoucherID");
|
||||
cmd.Parameters.AddWithValue("@VoucherID", voucherID);
|
||||
return BusinessObjectDAO<InventoryDisplayBO>.GetBusinessObjects(connection.ExecuteReader(cmd));
|
||||
return BusinessObjectDAO<InventoryBO>.GetBusinessObjects(connection.ExecuteReader(cmd));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -20,19 +20,21 @@ namespace Tanshu.Accounts.SqlDAO
|
||||
}
|
||||
public decimal GetBalance(decimal? tax)
|
||||
{
|
||||
// Will not work because of Vat / ServiceTax replacing Tax
|
||||
throw new NotImplementedException();
|
||||
string query;
|
||||
if (tax.HasValue)
|
||||
query = @"
|
||||
SELECT ISNULL(SUM(i.Amount), 0) FROM Vouchers t INNER JOIN SaleVoucher s ON t.VoucherID = s.VoucherID
|
||||
INNER JOIN Inventory i ON t.VoucherID = i.VoucherID
|
||||
WHERE t.Date BETWEEN @StartDate AND @FinishDate AND s.PaidStatus IN (2, 3)
|
||||
SELECT ISNULL(SUM(i.Amount), 0) FROM Vouchers v
|
||||
INNER JOIN Inventory i ON v.VoucherID = i.VoucherID
|
||||
WHERE v.Date BETWEEN @StartDate AND @FinishDate AND v.PaidStatus IN (2, 3)
|
||||
AND i.Tax = @Tax
|
||||
";
|
||||
else
|
||||
query = @"
|
||||
SELECT ISNULL(SUM(i.Amount), 0) FROM Vouchers t INNER JOIN SaleVoucher s ON t.VoucherID = s.VoucherID
|
||||
INNER JOIN Inventory i ON t.VoucherID = i.VoucherID
|
||||
WHERE t.Date BETWEEN @StartDate AND @FinishDate AND s.PaidStatus IN (2, 3)
|
||||
SELECT ISNULL(SUM(i.Amount), 0) FROM Vouchers v
|
||||
INNER JOIN Inventory i ON v.VoucherID = i.VoucherID
|
||||
WHERE v.Date BETWEEN @StartDate AND @FinishDate AND v.PaidStatus IN (2, 3)
|
||||
";
|
||||
using (var cmd = new SqlCommand(query))
|
||||
{
|
||||
@@ -45,14 +47,15 @@ WHERE t.Date BETWEEN @StartDate AND @FinishDate AND s.PaidStatus IN (2, 3)
|
||||
}
|
||||
public List<Guid> GetUpdateBillList(decimal tax)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
//Paid = 1, CC = 0, Void = 0
|
||||
var list = new List<Guid>();
|
||||
const string query = @"
|
||||
SELECT DISTINCT v.VoucherID
|
||||
FROM Vouchers v INNER JOIN SaleVoucher s ON v.VoucherID = s.VoucherID
|
||||
FROM Vouchers v
|
||||
INNER JOIN Inventory i ON v.VoucherID = i.VoucherID
|
||||
WHERE v.Date BETWEEN @StartDate AND @FinishDate
|
||||
AND s.PaidStatus = @Cash AND i.Tax = @Tax";
|
||||
AND v.PaidStatus = @Cash AND i.Tax = @Tax";
|
||||
using (var cmd = new SqlCommand(query))
|
||||
{
|
||||
cmd.Parameters.AddWithValue("@StartDate", startDate);
|
||||
@@ -72,12 +75,12 @@ AND s.PaidStatus = @Cash AND i.Tax = @Tax";
|
||||
public List<PendingBillsBO> GetPaidBills()
|
||||
{
|
||||
string query = @"
|
||||
SELECT t.VoucherID, s.TableID AS TableID,
|
||||
(SELECT SUM(Amount) FROM Inventory WHERE VoucherID = t.VoucherID) AS Amount,
|
||||
s.BillID, t.CreationDate, u.Name, CAST(0 AS bit), s.KotID, t.LastEditDate, s.Printed
|
||||
FROM Vouchers t INNER JOIN SaleVoucher s ON t.VoucherID = s.VoucherID AND s.Paid = 1 AND s.Void = 0
|
||||
INNER JOIN Users u ON t.UserID = u.UserID WHERE
|
||||
t.LastEditDate BETWEEN @StartDate AND @FinishDate ORDER BY t.CreationDate ";
|
||||
SELECT v.VoucherID, v.TableID AS TableID,
|
||||
(SELECT SUM(Amount) FROM Inventory WHERE VoucherID = v.VoucherID) AS Amount,
|
||||
v.BillID, v.CreationDate, u.Name, CAST(0 AS bit), v.KotID, v.LastEditDate, v.Printed
|
||||
FROM Vouchers v INNER JOIN Users u ON v.UserID = u.UserID
|
||||
WHERE v.LastEditDate BETWEEN @StartDate AND @FinishDate AND v.Paid = 1 AND v.Void = 0
|
||||
ORDER BY v.CreationDate;";
|
||||
using (SqlCommand cmd = new SqlCommand(query))
|
||||
{
|
||||
cmd.Parameters.AddWithValue("@StartDate", startDate);
|
||||
@@ -118,8 +121,8 @@ AND s.PaidStatus = @Cash AND i.Tax = @Tax";
|
||||
}
|
||||
using (SqlCommand cmd = new SqlCommand(@"
|
||||
DELETE FROM Inventory WHERE VoucherID = @VoucherID;
|
||||
DELETE FROM SaleVoucher WHERE VoucherID = @VoucherID;
|
||||
DELETE FROM Vouchers WHERE VoucherID = @VoucherID;"))
|
||||
DELETE FROM Vouchers WHERE VoucherID = @VoucherID;
|
||||
"))
|
||||
{
|
||||
cmd.Parameters.AddWithValue("@VoucherID", voucherID);
|
||||
connection.ExecuteNonQuery(cmd);
|
||||
@@ -132,7 +135,7 @@ DELETE FROM Vouchers WHERE VoucherID = @VoucherID;"))
|
||||
// {
|
||||
// string add = " WHERE ";
|
||||
// string query = @"
|
||||
//SELECT t.TransactionID AS transactionID, CAST (CASE WHEN Alarm IS NULL THEN 0 ELSE 1 END AS bit) AS Alarm,
|
||||
//SELECT v.TransactionID AS transactionID, CAST (CASE WHEN Alarm IS NULL THEN 0 ELSE 1 END AS bit) AS Alarm,
|
||||
//s.Alarm AS AlarmTime, s.TableID, (SELECT SUM(Amount) FROM Inventory i WHERE i.TransactionID = t.TransactionID) AS Amount,
|
||||
//s.BillID, t.CreationDate AS BookingTime, u.Name AS Cashier, s.Void AS Important,
|
||||
//s.KotID AS Kot, t.LastEditDate AS LastEdited, s.Printed AS Printed
|
||||
@@ -184,26 +187,21 @@ DELETE FROM Vouchers WHERE VoucherID = @VoucherID;"))
|
||||
showProgressDelegate(0, 0, 0, "Cleaning up Void Bills");
|
||||
using (SqlCommand cmd = new SqlCommand(@"
|
||||
DELETE FROM Inventory WHERE VoucherID IN (
|
||||
SELECT v.VoucherID FROM SaleVoucher s INNER JOIN Vouchers v ON s.VoucherID = v.VoucherID
|
||||
WHERE s.PaidStatus IN (1, 4, 5, 6) AND v.Date BETWEEN @StartDate AND @EndDate)
|
||||
SELECT v.VoucherID FROM Vouchers v
|
||||
WHERE v.PaidStatus IN (1, 4, 5, 6, 7) AND v.Date BETWEEN @StartDate AND @EndDate);
|
||||
|
||||
DELETE FROM SaleVoucher WHERE VoucherID IN (
|
||||
SELECT v.VoucherID FROM SaleVoucher s INNER JOIN Vouchers v ON s.VoucherID = v.VoucherID
|
||||
WHERE s.PaidStatus IN (1, 4, 5, 6) AND v.Date BETWEEN @StartDate AND @EndDate)
|
||||
|
||||
DELETE FROM Vouchers WHERE VoucherID NOT IN (SELECT VoucherID FROM SaleVoucher)
|
||||
AND Type = 'S'
|
||||
DELETE FROM Vouchers WHERE PaidStatus IN (1, 4, 5, 6, 7) AND Date BETWEEN @StartDate AND @EndDate;
|
||||
"))
|
||||
{
|
||||
cmd.Parameters.AddWithValue("@StartDate", startDate);
|
||||
cmd.Parameters.AddWithValue("@EndDate", finishDate);
|
||||
connection.ExecuteNonQuery(cmd);
|
||||
}
|
||||
List<SaleVoucherBO> list = new List<SaleVoucherBO>();
|
||||
var list = new List<VoucherBO>();
|
||||
using (SqlCommand cmd = new SqlCommand(@"
|
||||
SELECT v.VoucherID, s.BillID, v.Date
|
||||
FROM Vouchers v INNER JOIN SaleVoucher s ON v.VoucherID = s.VoucherID
|
||||
WHERE v.Date >= @StartDate AND s.Printed = 1
|
||||
SELECT v.VoucherID, v.BillID, v.Date
|
||||
FROM Vouchers v
|
||||
WHERE v.Date >= @StartDate AND v.Printed = 1
|
||||
ORDER BY Date"))
|
||||
{
|
||||
cmd.Parameters.AddWithValue("@StartDate", startDate);
|
||||
@@ -211,26 +209,26 @@ ORDER BY Date"))
|
||||
{
|
||||
while (dr.Read())
|
||||
{
|
||||
list.Add(new SaleVoucherBO { VoucherID = dr.GetGuid(0), BillID = dr.GetString(1), Date = dr.GetDateTime(2) });
|
||||
list.Add(new VoucherBO { VoucherID = dr.GetGuid(0), BillID = dr.GetString(1), Date = dr.GetDateTime(2) });
|
||||
}
|
||||
}
|
||||
}
|
||||
if (list.Count == 0)
|
||||
return;
|
||||
connection.ExecuteNonQuery("ALTER INDEX [IX_TransactionSale] ON [dbo].[SaleVoucher] DISABLE");
|
||||
connection.ExecuteNonQuery("ALTER INDEX [IX_TransactionSale] ON [dbo].[Vouchers] DISABLE");
|
||||
string billID = list[0].BillID;
|
||||
for (int i = 1; i < list.Count; i++)
|
||||
{
|
||||
billID = GetBillID(billID);
|
||||
showProgressDelegate(0, list.Count, i, string.Format("Fixing bill no {0}", billID));
|
||||
using (SqlCommand cmd = new SqlCommand("UPDATE SaleVoucher SET BillID = @BillID WHERE VoucherID = @VoucherID"))
|
||||
using (SqlCommand cmd = new SqlCommand("UPDATE Vouchers SET BillID = @BillID WHERE VoucherID = @VoucherID"))
|
||||
{
|
||||
cmd.Parameters.AddWithValue("@VoucherID", list[i].VoucherID);
|
||||
cmd.Parameters.AddWithValue("@BillID", billID);
|
||||
connection.ExecuteNonQuery(cmd);
|
||||
}
|
||||
}
|
||||
connection.ExecuteNonQuery("ALTER INDEX [IX_TransactionSale] ON [dbo].[SaleVoucher] REBUILD");
|
||||
connection.ExecuteNonQuery("ALTER INDEX [IX_TransactionSale] ON [dbo].[Vouchers] REBUILD");
|
||||
showProgressDelegate(0, list.Count, list.Count, "Cleanup finished");
|
||||
}
|
||||
|
||||
@@ -252,14 +250,14 @@ ORDER BY Date"))
|
||||
{
|
||||
DeleteTarget(sourceDB, targetDB);
|
||||
DateTime lastBillDateTime = GetBillDateTime(sourceDB, targetDB);
|
||||
using (var cmd = new SqlCommand(string.Format("ALTER INDEX [IX_TransactionSale] ON [{0}].[dbo].[SaleVoucher] DISABLE", targetDB)))
|
||||
using (var cmd = new SqlCommand(string.Format("ALTER INDEX [IX_TransactionSale] ON [{0}].[dbo].[Vouchers] DISABLE", targetDB)))
|
||||
{
|
||||
cmd.CommandTimeout = int.MaxValue;
|
||||
connection.ExecuteNonQuery(cmd);
|
||||
}
|
||||
CopyData(sourceDB, targetDB);
|
||||
Clean(sourceDB, targetDB, lastBillDateTime);
|
||||
using (var cmd = new SqlCommand(string.Format("ALTER INDEX [IX_TransactionSale] ON [{0}].[dbo].[SaleVoucher] REBUILD", targetDB)))
|
||||
using (var cmd = new SqlCommand(string.Format("ALTER INDEX [IX_TransactionSale] ON [{0}].[dbo].[Vouchers] REBUILD", targetDB)))
|
||||
{
|
||||
cmd.CommandTimeout = int.MaxValue;
|
||||
connection.ExecuteNonQuery(cmd);
|
||||
@@ -270,15 +268,10 @@ ORDER BY Date"))
|
||||
{
|
||||
string query = @"
|
||||
DELETE FROM {0}.dbo.Inventory WHERE VoucherID IN (
|
||||
SELECT v.VoucherID FROM {0}.dbo.SaleVoucher s INNER JOIN {0}.dbo.Vouchers v ON s.VoucherID = v.VoucherID
|
||||
WHERE v.Date BETWEEN @StartDate AND @EndDate)
|
||||
SELECT VoucherID FROM {0}.dbo.Vouchers
|
||||
WHERE Date BETWEEN @StartDate AND @EndDate);
|
||||
|
||||
DELETE FROM {0}.dbo.SaleVoucher WHERE VoucherID IN (
|
||||
SELECT v.VoucherID FROM {0}.dbo.SaleVoucher s INNER JOIN {0}.dbo.Vouchers v ON s.VoucherID = v.VoucherID
|
||||
WHERE v.Date BETWEEN @StartDate AND @EndDate)
|
||||
|
||||
DELETE FROM {0}.dbo.Vouchers WHERE VoucherID NOT IN (SELECT VoucherID FROM {0}.dbo.SaleVoucher)
|
||||
AND Type = 'S'
|
||||
DELETE FROM {0}.dbo.Vouchers WHERE Date BETWEEN @StartDate AND @EndDate;
|
||||
";
|
||||
using (SqlCommand cmd = new SqlCommand(string.Format(query, targetDB)))
|
||||
{
|
||||
@@ -291,9 +284,9 @@ AND Type = 'S'
|
||||
private DateTime GetBillDateTime(string sourceDB, string targetDB)
|
||||
{
|
||||
string query = @"
|
||||
SELECT TOP 1 v.Date
|
||||
FROM {0}.dbo.Vouchers v INNER JOIN {0}.dbo.SaleVoucher s ON v.VoucherID = s.VoucherID
|
||||
WHERE v.Date < @StartDate
|
||||
SELECT TOP 1 Date
|
||||
FROM {0}.dbo.Vouchers
|
||||
WHERE Date < @StartDate
|
||||
ORDER BY Date DESC";
|
||||
using (SqlCommand cmd = new SqlCommand(string.Format(query, targetDB)))
|
||||
{
|
||||
@@ -305,15 +298,10 @@ ORDER BY Date DESC";
|
||||
private void CopyData(string sourceDB, string targetDB)
|
||||
{
|
||||
string query = @"
|
||||
INSERT INTO {0}.dbo.Vouchers (VoucherID, Code, Ref, Date, Narration, UserID, CreationDate, LastEditDate, Type)
|
||||
SELECT VoucherID, Code, Ref, Date, Narration, UserID, CreationDate, LastEditDate, Type
|
||||
INSERT INTO {0}.dbo.Vouchers (VoucherID, Ref, Date, Narration, UserID, CreationDate, LastEditDate, Floor, BillID, TableID, WaiterID, CustomerID, AdvanceID, Paid, Void, VoidReason, Printed, Alarm, KotID)
|
||||
SELECT VoucherID, Ref, Date, Narration, UserID, CreationDate, LastEditDate, Floor, BillID, TableID, WaiterID, CustomerID, AdvanceID, Paid, Void, VoidReason, Printed, Alarm, KotID
|
||||
FROM {1}.dbo.Vouchers WHERE Date BETWEEN @StartDate AND @EndDate;
|
||||
|
||||
INSERT INTO {0}.dbo.SaleVoucher (VoucherID, BillID, TableID, WaiterID, CustomerID, Paid, Void, VoidReason, Printed, Alarm, KotID, CreditCard, IsImportant)
|
||||
SELECT VoucherID, BillID, TableID, WaiterID, CustomerID, Paid, Void, VoidReason, Printed, Alarm, KotID, CreditCard, IsImportant
|
||||
FROM {1}.dbo.SaleVoucher WHERE VoucherID IN (
|
||||
SELECT v.VoucherID FROM {1}.dbo.Vouchers v WHERE v.Date BETWEEN @StartDate AND @EndDate)
|
||||
|
||||
INSERT INTO {0}.dbo.Inventory (InventoryID, VoucherID, ProductID, Quantity, Rate, Tax, Discount)
|
||||
SELECT InventoryID, VoucherID, ProductID, Quantity, Rate, Tax, Discount
|
||||
FROM {1}.dbo.Inventory WHERE VoucherID IN (
|
||||
@@ -329,11 +317,11 @@ SELECT v.VoucherID FROM {1}.dbo.Vouchers v WHERE v.Date BETWEEN @StartDate AND @
|
||||
}
|
||||
private void Clean(string sourceDB, string targetDB, DateTime lastBillDateTime)
|
||||
{
|
||||
List<SaleVoucherBO> list = new List<SaleVoucherBO>();
|
||||
var list = new List<VoucherBO>();
|
||||
using (SqlCommand cmd = new SqlCommand(string.Format(@"
|
||||
SELECT v.VoucherID, s.BillID, v.Date
|
||||
FROM {0}.dbo.Vouchers v INNER JOIN {0}.dbo.SaleVoucher s ON v.VoucherID = s.VoucherID
|
||||
WHERE v.Date >= @StartDate AND s.Printed = 1
|
||||
SELECT VoucherID, BillID, Date
|
||||
FROM {0}.dbo.Vouchers
|
||||
WHERE Date >= @StartDate AND Printed = 1
|
||||
ORDER BY Date", targetDB)))
|
||||
{
|
||||
cmd.CommandTimeout = int.MaxValue;
|
||||
@@ -342,7 +330,7 @@ ORDER BY Date", targetDB)))
|
||||
{
|
||||
while (dr.Read())
|
||||
{
|
||||
list.Add(new SaleVoucherBO { VoucherID = dr.GetGuid(0), BillID = dr.GetString(1), Date = dr.GetDateTime(2) });
|
||||
list.Add(new VoucherBO { VoucherID = dr.GetGuid(0), BillID = dr.GetString(1), Date = dr.GetDateTime(2) });
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -350,7 +338,7 @@ ORDER BY Date", targetDB)))
|
||||
for (int i = 1; i < list.Count; i++)
|
||||
{
|
||||
billID = GetBillID(billID);
|
||||
using (SqlCommand cmd = new SqlCommand(string.Format("UPDATE {0}.dbo.SaleVoucher SET BillID = @BillID WHERE VoucherID = @VoucherID", targetDB)))
|
||||
using (SqlCommand cmd = new SqlCommand(string.Format("UPDATE {0}.dbo.Vouchers SET BillID = @BillID WHERE VoucherID = @VoucherID", targetDB)))
|
||||
{
|
||||
cmd.CommandTimeout = int.MaxValue;
|
||||
cmd.Parameters.AddWithValue("@VoucherID", list[i].VoucherID);
|
||||
|
||||
@@ -29,8 +29,8 @@ INSERT INTO Products (ProductID, Code, Name, ShortName, BarCode, Units, ProductG
|
||||
cmd.Parameters.AddWithValue("@Units", product.Units);
|
||||
cmd.Parameters.AddWithValue("@ProductGroupID", product.ProductGroupID);
|
||||
cmd.Parameters.AddWithValue("@VatID", product.VatID);
|
||||
cmd.Parameters.AddWithValue("@SalePrice", product.SalePrice);
|
||||
cmd.Parameters.AddWithValue("@ServiceTaxID", product.ServiceTaxID);
|
||||
cmd.Parameters.AddWithValue("@SalePrice", product.SalePrice);
|
||||
cmd.Parameters.AddWithValue("@Discontinued", product.Discontinued);
|
||||
cmd.Parameters.AddWithValue("@SortOrder", product.SortOrder);
|
||||
connection.ExecuteNonQuery(cmd);
|
||||
@@ -60,8 +60,8 @@ INSERT INTO Products (ProductID, Code, Name, ShortName, BarCode, Units, ProductG
|
||||
cmd.Parameters.AddWithValue("@Units", product.Units);
|
||||
cmd.Parameters.AddWithValue("@ProductGroupID", product.ProductGroupID);
|
||||
cmd.Parameters.AddWithValue("@VatID", product.VatID);
|
||||
cmd.Parameters.AddWithValue("@SalePrice", product.SalePrice);
|
||||
cmd.Parameters.AddWithValue("@ServiceTaxID", product.ServiceTaxID);
|
||||
cmd.Parameters.AddWithValue("@SalePrice", product.SalePrice);
|
||||
cmd.Parameters.AddWithValue("@Discontinued", product.Discontinued);
|
||||
cmd.Parameters.AddWithValue("@SortOrder", product.SortOrder);
|
||||
connection.ExecuteNonQuery(cmd);
|
||||
@@ -75,8 +75,7 @@ INSERT INTO Products (ProductID, Code, Name, ShortName, BarCode, Units, ProductG
|
||||
}
|
||||
public List<ProductDisplayBO> GetProducts()
|
||||
{
|
||||
//SELECT p.ProductID, p.Picture, p.Code, p.Name, p.Units, p.ProductGroupID, p.VatID, p.SalePrice, p.ServiceTaxID, p.Discontinued, p.SortOrder, pt.Name AS Type FROM Products p INNER JOIN ProductGroups pt ON p.ProductGroupID = pt.ProductGroupID ORDER BY p.Name
|
||||
SqlCommand cmd = new SqlCommand("SELECT p.ProductID, p.Picture, p.Code, p.Name, p.Units, p.ProductGroupID, p.VatID, p.SalePrice, p.ServiceTaxID, p.Discontinued, p.SortOrder, pt.Name AS Type FROM Products p INNER JOIN ProductGroups pt ON p.ProductGroupID = pt.ProductGroupID ORDER BY p.Name");
|
||||
SqlCommand cmd = new SqlCommand("SELECT p.ProductID, p.Code, p.Name, p.Units, p.ProductGroupID, p.VatID, p.SalePrice, p.ServiceTaxID, p.Discontinued, p.SortOrder, pt.Name AS Type FROM Products p INNER JOIN ProductGroups pt ON p.ProductGroupID = pt.ProductGroupID ORDER BY p.Name");
|
||||
return BusinessObjectDAO<ProductDisplayBO>.GetBusinessObjects(connection.ExecuteReader(cmd));
|
||||
}
|
||||
|
||||
@@ -110,9 +109,9 @@ INSERT INTO Products (ProductID, Code, Name, ShortName, BarCode, Units, ProductG
|
||||
SELECT p.ProductID, p.Code, p.Name + ' (' + p.Units + ') ' + ShortName AS Name,
|
||||
p.SalePrice, tv.Rate AS Vat, ts.Rate AS ServiceTax, pt.Name AS ProductGroup
|
||||
FROM Products p INNER JOIN Tax tv ON p.VatID = tv.TaxID
|
||||
INNER JOIN Tax ts ON p.ServiceTaxID = ts.TaxID
|
||||
INNER JOIN Tax ts ON p.ServiceTaxID = ts.TaxID
|
||||
INNER JOIN ProductGroups pt ON p.ProductGroupID = pt.ProductGroupID
|
||||
WHERE pt.IsForSale = 1 AND p.Discontinued = 0
|
||||
WHERE p.Discontinued = 0
|
||||
";
|
||||
string[] n = filter["Name"].Split(" ".ToCharArray());
|
||||
|
||||
@@ -177,6 +176,47 @@ SELECT TOP {1} p.*, pt.Name AS Type FROM ProductsRN p INNER JOIN ProductGroups p
|
||||
{
|
||||
return BusinessObjectDAO<TaxBO>.GetBusinessObjects(connection.ExecuteReader("SELECT * FROM Tax;"));
|
||||
}
|
||||
public SalesBillItemBO GetDefaultSaleBillItem(Guid productID)
|
||||
{
|
||||
const string query = @"
|
||||
SELECT p.ProductID, p.Name + ' (' + p.Units + ')', p.SalePrice,
|
||||
(SELECT Rate from Tax WHERE TaxID = p.VatID),
|
||||
(SELECT Rate from Tax WHERE TaxID = p.ServiceTaxID)
|
||||
FROM Products p
|
||||
WHERE p.ProductID = @ProductID
|
||||
";
|
||||
using (var cmd = new SqlCommand(query))
|
||||
{
|
||||
cmd.Parameters.AddWithValue("@ProductID", productID);
|
||||
using (var dr = connection.ExecuteReader(cmd))
|
||||
{
|
||||
dr.Read();
|
||||
var mySale = new SalesBillItemBO
|
||||
{
|
||||
productID = dr.GetGuid(0),
|
||||
Name = dr.GetString(1),
|
||||
Price = dr.GetDecimal(2),
|
||||
Vat = dr.GetDecimal(3),
|
||||
ServiceTax = dr.GetDecimal(4),
|
||||
Discount = 0,
|
||||
Printed = 0,
|
||||
Quantity = 1
|
||||
};
|
||||
return mySale;
|
||||
}
|
||||
}
|
||||
}
|
||||
public decimal GetProductDiscountLimit(Guid productID)
|
||||
{
|
||||
const string query = @"SELECT t.DiscountLimit FROM ProductGroups t INNER JOIN Products p ON t.ProductGroupID = p.ProductGroupID WHERE p.ProductID = @ProductID";
|
||||
|
||||
decimal discountLimit;
|
||||
using (var cmd = new SqlCommand(query))
|
||||
{
|
||||
cmd.Parameters.AddWithValue("@ProductID", productID);
|
||||
discountLimit = (decimal)connection.ExecuteScalar(cmd);
|
||||
}
|
||||
return discountLimit;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,170 +0,0 @@
|
||||
using System;
|
||||
using System.Data.SqlClient;
|
||||
using Tanshu.Accounts.Contracts;
|
||||
using Tanshu.Data.DAO;
|
||||
|
||||
|
||||
namespace Tanshu.Accounts.SqlDAO
|
||||
{
|
||||
public class SaleVoucherDAO : BaseDAO
|
||||
{
|
||||
public SaleVoucherDAO(IConnectionDAO connection)
|
||||
: base(connection)
|
||||
{ }
|
||||
|
||||
public bool Insert(SaleVoucherBO saleVoucher)
|
||||
{
|
||||
using (var cmd = new SqlCommand(@"
|
||||
SELECT @KotID = ISNULL('K-' + CAST(MAX(CAST(SUBSTRING(KotID, 3,8) AS int)) + 1 AS nvarchar(8)), 'K-1') FROM [dbo].[SaleVoucher]
|
||||
IF @Printed = 1
|
||||
BEGIN
|
||||
SELECT @BillID = ISNULL(CAST(MAX(CAST(REPLACE(BillID, '-', '') AS int)) + 1 AS nvarchar(9)), '010001') FROM SaleVoucher WHERE BillID LIKE '__-____'
|
||||
IF LEN(@BillID) = 5
|
||||
SET @BillID = '0' + @BillID
|
||||
SET @BillID = SUBSTRING(@BillID, 1, 2) + '-' + SUBSTRING(@BillID, 3, 7)
|
||||
IF SUBSTRING(@BillID,3,7) = '-0000'
|
||||
SET @BillID = SUBSTRING(@BillID, 1, 2) + '-0001'
|
||||
END
|
||||
ELSE
|
||||
BEGIN
|
||||
SET @BillID = @KotID
|
||||
END
|
||||
IF @TableID = ''
|
||||
BEGIN
|
||||
SELECT @TableID = 'C' + CAST(ISNULL(MAX(CAST(SUBSTRING(TableID, 2, 10) AS int)), 0) + 1 AS nvarchar(10)) FROM SaleVoucher WHERE TableID LIKE 'C%' AND PaidStatus = 1
|
||||
END
|
||||
INSERT INTO [dbo].[SaleVoucher] ([VoucherID], [Floor], [BillID], [TableID], [WaiterID], [CustomerID], [AdvanceID], [PaidStatus], [VoidReason], [Printed], [Alarm], [KotID])
|
||||
VALUES (@VoucherID, @Floor, @BillID, @TableID, @WaiterID, @CustomerID, @AdvanceID, @PaidStatus, @VoidReason, @Printed, @Alarm, @KotID)
|
||||
"))
|
||||
{
|
||||
cmd.Parameters.AddWithValue("@VoucherID", saleVoucher.VoucherID);
|
||||
cmd.Parameters.AddWithValue("@Floor", saleVoucher.Floor);
|
||||
cmd.Parameters.Add("@BillID", System.Data.SqlDbType.NVarChar, 10);
|
||||
cmd.Parameters["@BillID"].Direction = System.Data.ParameterDirection.Output;
|
||||
cmd.Parameters.AddWithValue("@TableID", saleVoucher.TableID);
|
||||
cmd.Parameters.AddWithValue("@WaiterID", saleVoucher.WaiterID);
|
||||
cmd.Parameters.AddWithValue("@CustomerID", saleVoucher.CustomerID);
|
||||
if (saleVoucher.AdvanceID.HasValue)
|
||||
cmd.Parameters.AddWithValue("@AdvanceID", saleVoucher.AdvanceID);
|
||||
else
|
||||
cmd.Parameters.AddWithValue("@AdvanceID", DBNull.Value);
|
||||
cmd.Parameters.AddWithValue("@PaidStatus", (int)saleVoucher.PaidStatus);
|
||||
if (saleVoucher.VoidReason == null)
|
||||
saleVoucher.VoidReason = string.Empty;
|
||||
cmd.Parameters.AddWithValue("@VoidReason", saleVoucher.VoidReason);
|
||||
cmd.Parameters.AddWithValue("@Printed", saleVoucher.Printed);
|
||||
if (saleVoucher.Alarm.HasValue)
|
||||
cmd.Parameters.AddWithValue("@Alarm", saleVoucher.Alarm);
|
||||
else
|
||||
cmd.Parameters.AddWithValue("@Alarm", DBNull.Value);
|
||||
cmd.Parameters.Add("@KotID", System.Data.SqlDbType.NVarChar, 10);
|
||||
cmd.Parameters["@KotID"].Direction = System.Data.ParameterDirection.Output;
|
||||
connection.ExecuteNonQuery(cmd);
|
||||
saleVoucher.BillID = (string)cmd.Parameters["@BillID"].Value;
|
||||
saleVoucher.KotID = (string)cmd.Parameters["@KotID"].Value;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
public bool Update(SaleVoucherBO saleVoucher)
|
||||
{
|
||||
using (var cmd = new SqlCommand(@"
|
||||
IF @Printed = 1 AND (SELECT Printed FROM SaleVoucher WHERE VoucherID = @VoucherID) = 0
|
||||
BEGIN
|
||||
SELECT @BillID = ISNULL(CAST(MAX(CAST(REPLACE(BillID, '-', '') AS int)) + 1 AS nvarchar(9)), '010001') FROM SaleVoucher WHERE BillID LIKE '__-____'
|
||||
IF LEN(@BillID) = 5
|
||||
SET @BillID = '0' + @BillID
|
||||
SET @BillID = SUBSTRING(@BillID, 1, 2) + '-' + SUBSTRING(@BillID, 3, 7)
|
||||
IF SUBSTRING(@BillID,3,7) = '-0000'
|
||||
SET @BillID = SUBSTRING(@BillID, 1, 2) + '-0001'
|
||||
END
|
||||
ELSE
|
||||
BEGIN
|
||||
SELECT @BillID = BillID FROM SaleVoucher WHERE VoucherID = @VoucherID
|
||||
END
|
||||
IF @TableID = ''
|
||||
BEGIN
|
||||
SELECT @TableID = 'C' + CAST(ISNULL(MAX(CAST(SUBSTRING(TableID, 2, 10) AS int)), 0) + 1 AS nvarchar(10)) FROM SaleVoucher WHERE TableID LIKE 'C%' AND PaidStatus = 1
|
||||
END
|
||||
IF (SELECT Printed FROM SaleVoucher WHERE VoucherID = @VoucherID) = 1
|
||||
SET @Printed = 1
|
||||
UPDATE [dbo].[SaleVoucher] SET
|
||||
[Floor] = @Floor,
|
||||
[BillID] = @BillID,
|
||||
[TableID] = @TableID,
|
||||
[WaiterID] = @WaiterID,
|
||||
[CustomerID] = @CustomerID,
|
||||
[AdvanceID] = @AdvanceID,
|
||||
[PaidStatus] = @PaidStatus,
|
||||
[VoidReason] = @VoidReason,
|
||||
[Printed] = @Printed,
|
||||
[Alarm] = @Alarm
|
||||
WHERE VoucherID = @VoucherID
|
||||
|
||||
UPDATE Vouchers SET LastEditDate = GETDATE() WHERE VoucherID = @VoucherID
|
||||
|
||||
SELECT @KotID = KotID FROM SaleVoucher WHERE VoucherID = @VoucherID
|
||||
"))
|
||||
{
|
||||
cmd.Parameters.AddWithValue("@VoucherID", saleVoucher.VoucherID);
|
||||
|
||||
cmd.Parameters.Add("@BillID", System.Data.SqlDbType.NVarChar, 10);
|
||||
cmd.Parameters["@BillID"].Direction = System.Data.ParameterDirection.Output;
|
||||
cmd.Parameters.AddWithValue("@Floor", saleVoucher.Floor);
|
||||
cmd.Parameters.AddWithValue("@TableID", saleVoucher.TableID);
|
||||
cmd.Parameters.AddWithValue("@WaiterID", saleVoucher.WaiterID);
|
||||
cmd.Parameters.AddWithValue("@CustomerID", saleVoucher.CustomerID);
|
||||
if (saleVoucher.AdvanceID.HasValue)
|
||||
cmd.Parameters.AddWithValue("@AdvanceID", saleVoucher.AdvanceID);
|
||||
else
|
||||
cmd.Parameters.AddWithValue("@AdvanceID", DBNull.Value);
|
||||
cmd.Parameters.AddWithValue("@PaidStatus", saleVoucher.PaidStatus);
|
||||
if (saleVoucher.VoidReason == null)
|
||||
saleVoucher.VoidReason = string.Empty;
|
||||
cmd.Parameters.AddWithValue("@VoidReason", saleVoucher.VoidReason);
|
||||
cmd.Parameters.AddWithValue("@Printed", saleVoucher.Printed);
|
||||
if (saleVoucher.Alarm.HasValue)
|
||||
cmd.Parameters.AddWithValue("@Alarm", saleVoucher.Alarm);
|
||||
else
|
||||
cmd.Parameters.AddWithValue("@Alarm", DBNull.Value);
|
||||
cmd.Parameters.Add("@KotID", System.Data.SqlDbType.NVarChar, 10);
|
||||
cmd.Parameters["@KotID"].Direction = System.Data.ParameterDirection.Output;
|
||||
connection.ExecuteNonQuery(cmd);
|
||||
saleVoucher.BillID = (string)cmd.Parameters["@BillID"].Value;
|
||||
saleVoucher.KotID = (string)cmd.Parameters["@KotID"].Value;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
public void SetAlarm(Guid voucherID, DateTime? alarmTime)
|
||||
{
|
||||
using (SqlCommand cmd = new SqlCommand(@"UPDATE SaleVoucher SET Alarm = @Alarm WHERE VoucherID = @VoucherID"))
|
||||
{
|
||||
cmd.Parameters.AddWithValue("@VoucherID", voucherID);
|
||||
cmd.Parameters.AddWithValue("@Alarm", alarmTime);
|
||||
connection.ExecuteNonQuery(cmd);
|
||||
}
|
||||
}
|
||||
public void VoidBill(Guid voucherID, string reason, Guid userID)
|
||||
{
|
||||
using (SqlCommand cmd = new SqlCommand(@"UPDATE SaleVoucher SET PaidStatus = @PaidStatus, VoidReason = @VoidReason WHERE VoucherID = @VoucherID; UPDATE Vouchers SET UserID = @UserID, LastEditDate = GETDATE() WHERE VoucherID = @VoucherID"))
|
||||
{
|
||||
cmd.Parameters.AddWithValue("@VoucherID", voucherID);
|
||||
cmd.Parameters.AddWithValue("@UserID", userID);
|
||||
cmd.Parameters.AddWithValue("@PaidStatus", (int)PaidStatus.Void);
|
||||
cmd.Parameters.AddWithValue("@VoidReason", reason);
|
||||
connection.ExecuteNonQuery(cmd);
|
||||
}
|
||||
}
|
||||
public SaleVoucherBO GetVoucherSale(Guid voucherID)
|
||||
{
|
||||
var cmd = new SqlCommand("SELECT b.*, ts.Floor, ts.BillID, ts.TableID, ts.WaiterID, ts.CustomerID, ts.AdvanceID, ts.PaidStatus, ts.VoidReason, ts.Printed, ts.Alarm, ts.KotID FROM SaleVoucher ts INNER JOIN Vouchers b ON ts.VoucherID = b.VoucherID WHERE ts.VoucherID = @VoucherID");
|
||||
cmd.Parameters.AddWithValue("@VoucherID", voucherID);
|
||||
return BusinessObjectDAO<SaleVoucherBO>.GetBusinessObject(connection.ExecuteReader(cmd));
|
||||
}
|
||||
public SaleVoucherBO GetVoucherSale(string billID)
|
||||
{
|
||||
var cmd = new SqlCommand("SELECT b.*, ts.Floor, ts.BillID, ts.TableID, ts.WaiterID, ts.CustomerID, ts.AdvanceID, ts.PaidStatus, ts.VoidReason, ts.Printed, ts.Alarm, ts.KotID FROM SaleVoucher ts INNER JOIN Vouchers b ON ts.VoucherID = b.VoucherID WHERE ts.BillID = @billID");
|
||||
cmd.Parameters.AddWithValue("@billID", billID);
|
||||
return BusinessObjectDAO<SaleVoucherBO>.GetBusinessObject(connection.ExecuteReader(cmd));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,249 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Tanshu.Accounts.Contracts;
|
||||
using System.Data.SqlClient;
|
||||
using Tanshu.Data.DAO;
|
||||
|
||||
|
||||
|
||||
namespace Tanshu.Accounts.SqlDAO
|
||||
{
|
||||
public class SaleVoucherMixDAO : BaseDAO
|
||||
{
|
||||
public SaleVoucherMixDAO(IConnectionDAO connection)
|
||||
: base(connection)
|
||||
{ }
|
||||
public SalesBillItemBO GetDefaultSaleBillItem(Guid productID)
|
||||
{
|
||||
const string query = @"
|
||||
SELECT p.ProductID, p.Name + ' (' + p.Units +')', p.SalePrice, tv.Rate, ts.Rate, p.ProductGroupID
|
||||
FROM Products p INNER JOIN Tax tv ON p.VatID = tv.TaxID
|
||||
INNER JOIN Tax ts ON p.ServiceTaxID = ts.TaxID
|
||||
WHERE p.ProductID = @ProductID
|
||||
";
|
||||
using (var cmd = new SqlCommand(query))
|
||||
{
|
||||
cmd.Parameters.AddWithValue("@ProductID", productID);
|
||||
using (var dr = connection.ExecuteReader(cmd))
|
||||
{
|
||||
dr.Read();
|
||||
var mySale = new SalesBillItemBO
|
||||
{
|
||||
productID = dr.GetGuid(0),
|
||||
Name = dr.GetString(1),
|
||||
Price = dr.GetDecimal(2),
|
||||
Vat = dr.GetDecimal(3),
|
||||
ServiceTax = dr.GetDecimal(4),
|
||||
Discount = 0,
|
||||
location = "",
|
||||
Printed = 0,
|
||||
Quantity = 1
|
||||
};
|
||||
return mySale;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public decimal GetProductDiscountLimit(Guid productID)
|
||||
{
|
||||
const string query = @"SELECT t.DiscountLimit FROM ProductGroups t INNER JOIN Products p ON t.ProductGroupID = p.ProductGroupID WHERE p.ProductID = @ProductID";
|
||||
|
||||
decimal discountLimit;
|
||||
using (var cmd = new SqlCommand(query))
|
||||
{
|
||||
cmd.Parameters.AddWithValue("@ProductID", productID);
|
||||
discountLimit = (decimal)connection.ExecuteScalar(cmd);
|
||||
}
|
||||
return discountLimit;
|
||||
}
|
||||
public bool IsBillPrinted(Guid voucherID)
|
||||
{
|
||||
const string query = @"SELECT Printed FROM SaleVoucher WHERE VoucherID = @VoucherID";
|
||||
using (var cmd = new SqlCommand(query))
|
||||
{
|
||||
cmd.Parameters.AddWithValue("@VoucherID", voucherID);
|
||||
return (bool)connection.ExecuteScalar(cmd);
|
||||
}
|
||||
}
|
||||
|
||||
public List<PendingBillsBO> GetPendingBills(PendingType list, int floor)
|
||||
{
|
||||
var query = @"
|
||||
SELECT t.VoucherID, s.Alarm AS Alarm, s.TableID AS TableID,
|
||||
(SELECT SUM(Amount) FROM Inventory WHERE VoucherID = t.VoucherID) AS Amount,
|
||||
s.BillID, t.CreationDate, u.Name, CAST(0 AS bit), s.KotID, t.LastEditDate, s.Printed, s.AdvanceID
|
||||
FROM Vouchers t INNER JOIN SaleVoucher s ON t.VoucherID = s.VoucherID AND s.PaidStatus = @PaidStatus
|
||||
INNER JOIN Users u ON t.UserID = u.UserID
|
||||
";
|
||||
if (list == PendingType.Alarms)
|
||||
query += "WHERE s.Alarm IS NOT NULL ";
|
||||
else
|
||||
query += "WHERE s.Alarm IS NULL ";
|
||||
if (floor != 0)
|
||||
query += "AND s.Floor = @Floor ";
|
||||
if (list == PendingType.Today)
|
||||
query += string.Format("AND t.LastEditDate >= '{0:dd-MMM-yyyy} 00:00:00' ", DateTime.Now);
|
||||
else if (list == PendingType.Week)
|
||||
query += string.Format("AND t.LastEditDate >= '{0:dd-MMM-yyyy} 00:00:00' ", DateTime.Now.AddDays(-7));
|
||||
query += "ORDER BY t.CreationDate ";
|
||||
using (var cmd = new SqlCommand(query))
|
||||
{
|
||||
cmd.Parameters.AddWithValue("@PaidStatus", (int)PaidStatus.Pending);
|
||||
if (floor != 0)
|
||||
cmd.Parameters.AddWithValue("@Floor", floor);
|
||||
using (var dr = connection.ExecuteReader(cmd))
|
||||
{
|
||||
var outList = new List<PendingBillsBO>();
|
||||
while (dr.Read())
|
||||
{
|
||||
var local = new PendingBillsBO();
|
||||
local.voucherID = dr.GetGuid(0);
|
||||
local.Alarm = !dr.IsDBNull(1);
|
||||
if (local.Alarm)
|
||||
local.AlarmTime = dr.GetDateTime(1);
|
||||
local.TableID = dr.GetString(2);
|
||||
if (!dr.IsDBNull(3))
|
||||
local.Amount = dr.GetDecimal(3);
|
||||
local.BillNo = dr.GetString(4);
|
||||
local.BookingTime = dr.GetDateTime(5);
|
||||
local.Cashier = dr.GetString(6);
|
||||
local.Important = dr.GetBoolean(7);
|
||||
local.Kot = dr.GetString(8);
|
||||
local.LastEdited = dr.GetDateTime(9);
|
||||
local.Printed = dr.GetBoolean(10);
|
||||
if (!dr.IsDBNull(11))
|
||||
local.AdvanceID = dr.GetGuid(11);
|
||||
outList.Add(local);
|
||||
}
|
||||
return outList;
|
||||
}
|
||||
}
|
||||
}
|
||||
public Guid? GetPendingVoucherID(string tableID, int floor)
|
||||
{
|
||||
var query = "SELECT VoucherID FROM SaleVoucher where TableID = @TableID and PaidStatus = @PaidStatus";
|
||||
if (floor != 0)
|
||||
query += " AND Floor = @Floor ";
|
||||
using (var cmd = new SqlCommand(query))
|
||||
{
|
||||
cmd.Parameters.AddWithValue("@TableID", tableID);
|
||||
cmd.Parameters.AddWithValue("@PaidStatus", (int)PaidStatus.Pending);
|
||||
if (floor != 0)
|
||||
cmd.Parameters.AddWithValue("@Floor", floor);
|
||||
using (var dr = connection.ExecuteReader(cmd))
|
||||
{
|
||||
if (dr.Read())
|
||||
{
|
||||
return dr.GetGuid(0);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
public List<InventoryBO> SaleInventory(Dictionary<BillItemKey, SalesBillItemBO>.ValueCollection list, Guid? voucherID)
|
||||
{
|
||||
var localList = new Dictionary<Guid, InventoryBO>();
|
||||
foreach (var item in list)
|
||||
{
|
||||
var temp = new InventoryBO();
|
||||
if (localList.ContainsKey(item.productID))
|
||||
{
|
||||
temp = localList[item.productID];
|
||||
temp.Quantity += item.Quantity;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (voucherID.HasValue)
|
||||
temp.VoucherID = voucherID.Value;
|
||||
temp.InventoryID = Guid.NewGuid();
|
||||
temp.Discount = item.Discount;
|
||||
temp.ProductID = item.productID;
|
||||
temp.Quantity = item.Quantity;
|
||||
temp.Rate = item.Price;
|
||||
temp.Vat = item.Vat;
|
||||
temp.ServiceTax = item.ServiceTax;
|
||||
localList.Add(item.productID, temp);
|
||||
}
|
||||
}
|
||||
var outList = new List<InventoryBO>();
|
||||
foreach (var item in localList)
|
||||
outList.Add(item.Value);
|
||||
return outList;
|
||||
}
|
||||
|
||||
private class BillPaidClass
|
||||
{
|
||||
public Guid VoucherID { get; set; }
|
||||
public string KotID { get; set; }
|
||||
public bool Printed { get; set; }
|
||||
}
|
||||
public void DeclareBillsPaid(Guid userID, List<Guid> billList, PaidStatus paidStatus)
|
||||
{
|
||||
var removeItems = new List<Guid>();
|
||||
var query = "SELECT VoucherID, KotID, Printed FROM SaleVoucher WHERE VoucherID IN (";
|
||||
foreach (var voucherID in billList)
|
||||
{
|
||||
query += string.Format("'{0}', ", voucherID);
|
||||
}
|
||||
query = query.Substring(0, query.Length - 2) + ")";
|
||||
|
||||
var pbc = new List<BillPaidClass>();
|
||||
using (var cmd = new SqlCommand(query))
|
||||
{
|
||||
using (var dr = connection.ExecuteReader(cmd))
|
||||
{
|
||||
while (dr.Read())
|
||||
{
|
||||
pbc.Add(new BillPaidClass
|
||||
{
|
||||
VoucherID = dr.GetGuid(0),
|
||||
KotID = dr.GetString(1),
|
||||
Printed = dr.GetBoolean(2)
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
foreach (var item in pbc)
|
||||
{
|
||||
//if ((item.Printed != false) || (MessageBox.Show("Pay unprinted bill No.: " + item.KotID + " ?", "Pay unprinted bill", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.Yes))
|
||||
if (!item.Printed)
|
||||
continue;
|
||||
using (var cmd = new SqlCommand("UPDATE SaleVoucher SET PaidStatus = @PaidStatus WHERE VoucherID = @VoucherID; UPDATE Vouchers SET UserID = @UserID, LastEditDate = GETDATE() WHERE VoucherID = @VoucherID"))
|
||||
{
|
||||
cmd.Parameters.AddWithValue("@VoucherID", item.VoucherID);
|
||||
cmd.Parameters.AddWithValue("@UserID", userID);
|
||||
cmd.Parameters.AddWithValue("@PaidStatus", (int)paidStatus);
|
||||
connection.ExecuteNonQuery(cmd);
|
||||
}
|
||||
removeItems.Add(item.VoucherID);
|
||||
}
|
||||
|
||||
foreach (var item in removeItems)
|
||||
billList.Remove(item);
|
||||
}
|
||||
#region ISaleVoucherMixDAO Members
|
||||
public decimal Amount(Guid voucherID)
|
||||
{
|
||||
decimal amount;
|
||||
using (var cmd = new SqlCommand("SELECT SUM(Amount) FROM Inventory WHERE VoucherID = @VoucherID"))
|
||||
{
|
||||
cmd.Parameters.AddWithValue("@VoucherID", voucherID);
|
||||
amount = (decimal)connection.ExecuteScalar(cmd);
|
||||
}
|
||||
object advanceID;
|
||||
using (var cmd = new SqlCommand("SELECT AdvanceID FROM SaleVoucher WHERE VoucherID = @VoucherID"))
|
||||
{
|
||||
cmd.Parameters.AddWithValue("@VoucherID", voucherID);
|
||||
advanceID = connection.ExecuteScalar(cmd);
|
||||
if (advanceID == DBNull.Value)
|
||||
return amount;
|
||||
}
|
||||
using (var cmd = new SqlCommand("SELECT Amount FROM Advances WHERE AdvanceID = @AdvanceID"))
|
||||
{
|
||||
cmd.Parameters.AddWithValue("@AdvanceID", (Guid)advanceID);
|
||||
return amount - (decimal)connection.ExecuteScalar(cmd);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -13,7 +13,7 @@ namespace Tanshu.Accounts.SqlDAO
|
||||
: base(connection)
|
||||
{ }
|
||||
|
||||
public List<SalesAnalysisBO> GetSalesTaxReturn(DateTime startDate, DateTime finishDate, ref decimal freeSale, ref decimal voids, ref decimal pending, ref decimal net, ref decimal tax)
|
||||
public List<SalesAnalysisBO> GetSalesTaxReturn(DateTime startDate, DateTime finishDate, ref decimal voids, ref decimal pending, ref decimal net, ref decimal vat, ref decimal serviceTax, ref decimal nc)
|
||||
{
|
||||
var list = new List<SalesAnalysisBO>();
|
||||
using (var cmd = new SqlCommand())
|
||||
@@ -24,15 +24,15 @@ CAST(i.Tax AS nvarchar(10)) AS Section,
|
||||
SUM(i.Quantity * i.Rate * (1 - i.Discount) * (i.Tax)) AS Quantity,
|
||||
SUM(i.Quantity * i.Rate * (1 - i.Discount)) AS Net,
|
||||
SUM(i.Amount) AS Gross
|
||||
FROM Vouchers t INNER JOIN SaleVoucher s ON t.VoucherID = s.VoucherID
|
||||
INNER JOIN Inventory i ON t.VoucherID = i.VoucherID
|
||||
WHERE s.PaidStatus != @Pending AND s.PaidStatus != @Void
|
||||
AND t.Date BETWEEN @StartDate AND @FinishDate
|
||||
FROM Vouchers v INNER JOIN Inventory i ON v.VoucherID = i.VoucherID
|
||||
WHERE v.PaidStatus NOT IN (@Pending, @Void, @Nc)
|
||||
AND v.Date BETWEEN @StartDate AND @FinishDate
|
||||
GROUP BY i.Tax
|
||||
ORDER BY Section DESC;";
|
||||
cmd.CommandText = query;
|
||||
cmd.Parameters.AddWithValue("@Pending", (int)PaidStatus.Pending);
|
||||
cmd.Parameters.AddWithValue("@Void", (int)PaidStatus.Void);
|
||||
cmd.Parameters.AddWithValue("@Nc", (int)PaidStatus.Nc);
|
||||
cmd.Parameters.AddWithValue("@StartDate", startDate);
|
||||
cmd.Parameters.AddWithValue("@FinishDate", finishDate);
|
||||
list = BusinessObjectDAO<SalesAnalysisBO>.GetBusinessObjects(connection.ExecuteReader(cmd));
|
||||
@@ -42,27 +42,25 @@ ORDER BY Section DESC;";
|
||||
using (var cmd = new SqlCommand())
|
||||
{
|
||||
const string query = @"
|
||||
SELECT ISNULL(SUM(Quantity * Rate), 0) AS Amount
|
||||
FROM Vouchers t INNER JOIN SaleVoucher s ON t.VoucherID = s.VoucherID
|
||||
INNER JOIN Inventory i ON t.VoucherID = i.VoucherID
|
||||
WHERE s.PaidStatus != @Pending AND s.PaidStatus != @Void
|
||||
AND t.Date BETWEEN @StartDate AND @FinishDate
|
||||
AND i.Amount = 0";
|
||||
SELECT ISNULL(SUM(i.Quantity * i.Rate), 0) AS Amount
|
||||
FROM Vouchers v
|
||||
INNER JOIN Inventory i ON v.VoucherID = i.VoucherID
|
||||
WHERE v.PaidStatus = @Nc
|
||||
AND v.Date BETWEEN @StartDate AND @FinishDate
|
||||
";
|
||||
cmd.CommandText = query;
|
||||
cmd.Parameters.AddWithValue("@Pending", (int)PaidStatus.Pending);
|
||||
cmd.Parameters.AddWithValue("@Void", (int)PaidStatus.Void);
|
||||
cmd.Parameters.AddWithValue("@Nc", (int)PaidStatus.Nc);
|
||||
cmd.Parameters.AddWithValue("@StartDate", startDate);
|
||||
cmd.Parameters.AddWithValue("@FinishDate", finishDate);
|
||||
freeSale = Math.Round((decimal)connection.ExecuteScalar(cmd));
|
||||
nc = Math.Round((decimal)connection.ExecuteScalar(cmd));
|
||||
}
|
||||
using (var cmd = new SqlCommand())
|
||||
{
|
||||
const string query = @"
|
||||
SELECT ISNULL(SUM(Amount), 0) AS Amount
|
||||
FROM Vouchers t INNER JOIN SaleVoucher s ON t.VoucherID = s.VoucherID
|
||||
INNER JOIN Inventory i ON t.VoucherID = i.VoucherID
|
||||
WHERE t.Date BETWEEN @StartDate AND @FinishDate
|
||||
AND s.PaidStatus = @Void";
|
||||
SELECT ISNULL(SUM(i.Amount), 0) AS Amount
|
||||
FROM Vouchers v INNER JOIN Inventory i ON v.VoucherID = i.VoucherID
|
||||
WHERE v.Date BETWEEN @StartDate AND @FinishDate
|
||||
AND v.PaidStatus = @Void";
|
||||
cmd.CommandText = query;
|
||||
cmd.Parameters.AddWithValue("@Void", (int)PaidStatus.Void);
|
||||
cmd.Parameters.AddWithValue("@StartDate", startDate);
|
||||
@@ -72,11 +70,10 @@ AND s.PaidStatus = @Void";
|
||||
using (var cmd = new SqlCommand())
|
||||
{
|
||||
const string query = @"
|
||||
SELECT ISNULL(SUM(Amount), 0) AS Amount
|
||||
FROM Vouchers t INNER JOIN SaleVoucher s ON t.VoucherID = s.VoucherID
|
||||
INNER JOIN Inventory i ON t.VoucherID = i.VoucherID
|
||||
WHERE s.PaidStatus = @Pending
|
||||
AND t.Date BETWEEN @StartDate AND @FinishDate";
|
||||
SELECT ISNULL(SUM(i.Amount), 0) AS Amount
|
||||
FROM Vouchers v INNER JOIN Inventory i ON v.VoucherID = i.VoucherID
|
||||
WHERE v.PaidStatus = @Pending
|
||||
AND v.Date BETWEEN @StartDate AND @FinishDate";
|
||||
cmd.CommandText = query;
|
||||
cmd.Parameters.AddWithValue("@Pending", (int)PaidStatus.Pending);
|
||||
cmd.Parameters.AddWithValue("@StartDate", startDate);
|
||||
@@ -87,13 +84,13 @@ AND t.Date BETWEEN @StartDate AND @FinishDate";
|
||||
{
|
||||
const string query = @"
|
||||
SELECT ISNULL(SUM(Quantity * Rate * (1 - Discount )), 0) AS Amount
|
||||
FROM Vouchers t INNER JOIN SaleVoucher s ON t.VoucherID = s.VoucherID
|
||||
INNER JOIN Inventory i ON t.VoucherID = i.VoucherID
|
||||
WHERE s.PaidStatus != @Pending AND s.PaidStatus != @Void
|
||||
AND t.Date BETWEEN @StartDate AND @FinishDate";
|
||||
FROM Vouchers v INNER JOIN Inventory i ON v.VoucherID = i.VoucherID
|
||||
WHERE v.PaidStatus NOT IN (@Pending, @Void, @Nc)
|
||||
AND v.Date BETWEEN @StartDate AND @FinishDate";
|
||||
cmd.CommandText = query;
|
||||
cmd.Parameters.AddWithValue("@Pending", (int)PaidStatus.Pending);
|
||||
cmd.Parameters.AddWithValue("@Void", (int)PaidStatus.Void);
|
||||
cmd.Parameters.AddWithValue("@Nc", (int)PaidStatus.Nc);
|
||||
cmd.Parameters.AddWithValue("@StartDate", startDate);
|
||||
cmd.Parameters.AddWithValue("@FinishDate", finishDate);
|
||||
net = Math.Round((decimal)connection.ExecuteScalar(cmd));
|
||||
@@ -101,51 +98,46 @@ AND t.Date BETWEEN @StartDate AND @FinishDate";
|
||||
using (var cmd = new SqlCommand())
|
||||
{
|
||||
const string query = @"
|
||||
SELECT ISNULL(SUM(Amount), 0) AS Amount
|
||||
FROM Vouchers t INNER JOIN SaleVoucher s ON t.VoucherID = s.VoucherID
|
||||
INNER JOIN Inventory i ON t.VoucherID = i.VoucherID
|
||||
WHERE s.PaidStatus != @Pending AND s.PaidStatus != @Void
|
||||
AND t.Date BETWEEN @StartDate AND @FinishDate";
|
||||
SELECT ISNULL(SUM(i.Quantity * i.Rate * (1 - i.Discount) * i.Vat), 0) AS Amount
|
||||
FROM Vouchers v INNER JOIN Inventory i ON v.VoucherID = i.VoucherID
|
||||
WHERE v.PaidStatus NOT IN (@Pending, @Void, @Nc)
|
||||
AND v.Date BETWEEN @StartDate AND @FinishDate";
|
||||
cmd.CommandText = query;
|
||||
cmd.Parameters.AddWithValue("@Pending", (int)PaidStatus.Pending);
|
||||
cmd.Parameters.AddWithValue("@Void", (int)PaidStatus.Void);
|
||||
cmd.Parameters.AddWithValue("@Nc", (int)PaidStatus.Nc);
|
||||
cmd.Parameters.AddWithValue("@StartDate", startDate);
|
||||
cmd.Parameters.AddWithValue("@FinishDate", finishDate);
|
||||
tax = Math.Round((decimal)connection.ExecuteScalar(cmd));
|
||||
vat = Math.Round((decimal)connection.ExecuteScalar(cmd));
|
||||
}
|
||||
return list;
|
||||
}
|
||||
public decimal GetFreeSale(DateTime startDate, DateTime finishDate)
|
||||
{
|
||||
using (var cmd = new SqlCommand())
|
||||
{
|
||||
const string query = @"
|
||||
SELECT ISNULL(SUM(Quantity * Rate), 0) AS Amount
|
||||
FROM Vouchers t INNER JOIN SaleVoucher s ON t.VoucherID = s.VoucherID
|
||||
INNER JOIN Inventory i ON t.VoucherID = i.VoucherID
|
||||
WHERE s.PaidStatus != @Pending AND s.PaidStatus != @Void
|
||||
AND t.LastEditDate BETWEEN @StartDate AND @FinishDate
|
||||
AND i.Amount = 0";
|
||||
SELECT ISNULL(SUM(i.Quantity * i.Rate * (1 - i.Discount) * i.ServiceTax), 0) AS Amount
|
||||
FROM Vouchers v INNER JOIN Inventory i ON v.VoucherID = i.VoucherID
|
||||
WHERE v.PaidStatus NOT IN (@Pending, @Void, @Nc)
|
||||
AND v.Date BETWEEN @StartDate AND @FinishDate";
|
||||
cmd.CommandText = query;
|
||||
cmd.Parameters.AddWithValue("@Pending", (int)PaidStatus.Pending);
|
||||
cmd.Parameters.AddWithValue("@Void", (int)PaidStatus.Void);
|
||||
cmd.Parameters.AddWithValue("@Nc", (int)PaidStatus.Nc);
|
||||
cmd.Parameters.AddWithValue("@StartDate", startDate);
|
||||
cmd.Parameters.AddWithValue("@FinishDate", finishDate);
|
||||
return Math.Round((decimal)connection.ExecuteScalar(cmd));
|
||||
serviceTax = Math.Round((decimal)connection.ExecuteScalar(cmd));
|
||||
}
|
||||
return list;
|
||||
}
|
||||
public List<SalesAnalysisDetailBO> GetSaleDetail(DateTime startDate, DateTime finishDate, Guid productGroupID)
|
||||
{
|
||||
using (SqlCommand cmd = new SqlCommand())
|
||||
{
|
||||
string query = @"
|
||||
SELECT p.Name AS Product, pt.Name AS Section, SUM(i.Quantity) AS Quantity, SUM(Amount) AS Amount
|
||||
FROM Vouchers t INNER JOIN SaleVoucher s ON t.VoucherID = s.VoucherID
|
||||
INNER JOIN Inventory i ON t.VoucherID = i.VoucherID
|
||||
SELECT p.Name AS Product, pt.Name AS Section, SUM(i.Quantity) AS Quantity, SUM(i.Amount) AS Amount
|
||||
FROM Vouchers v INNER JOIN Inventory i ON v.VoucherID = i.VoucherID
|
||||
INNER JOIN Products p ON i.ProductID = p.ProductID
|
||||
INNER JOIN ProductGroups pt ON p.ProductGroupID = pt.ProductGroupID
|
||||
WHERE s.PaidStatus != @Pending AND s.PaidStatus != @Void
|
||||
AND t.LastEditDate BETWEEN @StartDate AND @FinishDate AND p.ProductGroupID = @ProductGroupID
|
||||
WHERE v.PaidStatus != @Pending AND v.PaidStatus != @Void
|
||||
AND v.LastEditDate BETWEEN @StartDate AND @FinishDate AND p.ProductGroupID = @ProductGroupID
|
||||
GROUP BY p.Name, pt.Name
|
||||
ORDER BY Amount DESC;";
|
||||
cmd.CommandText = query;
|
||||
@@ -164,12 +156,12 @@ ORDER BY Amount DESC;";
|
||||
{
|
||||
const string query = @"
|
||||
SELECT pg.ProductGroupID, pg.Name, SUM(i.Quantity * i.Rate * (1 - i.Discount)) AS Net, SUM(i.Quantity * i.Rate * (1 - i.Discount) * i.Vat) AS Vat, SUM(i.Quantity * i.Rate * (1 - i.Discount) * i.ServiceTax) AS ServiceTax
|
||||
FROM Vouchers t INNER JOIN SaleVoucher s ON t.VoucherID = s.VoucherID
|
||||
INNER JOIN Inventory i ON t.VoucherID = i.VoucherID
|
||||
FROM Vouchers v
|
||||
INNER JOIN Inventory i ON v.VoucherID = i.VoucherID
|
||||
INNER JOIN Products p ON i.ProductID = p.ProductID
|
||||
INNER JOIN ProductGroups pg ON p.ProductGroupID = pg.ProductGroupID
|
||||
WHERE s.PaidStatus != @Pending AND s.PaidStatus != @Void
|
||||
AND t.LastEditDate BETWEEN @StartDate AND @FinishDate
|
||||
WHERE v.PaidStatus != @Pending AND v.PaidStatus != @Void
|
||||
AND v.LastEditDate BETWEEN @StartDate AND @FinishDate
|
||||
GROUP BY pg.ProductGroupID, pg.Name
|
||||
ORDER BY Net DESC;";
|
||||
cmd.CommandText = query;
|
||||
@@ -205,12 +197,12 @@ ORDER BY Net DESC;";
|
||||
using (var cmd = new SqlCommand())
|
||||
{
|
||||
const string query = @"
|
||||
SELECT s.PaidStatus AS Status, Sum(i.Amount) AS Amount
|
||||
FROM Vouchers v INNER JOIN SaleVoucher s ON v.VoucherID = s.VoucherID
|
||||
SELECT v.PaidStatus AS Status, Sum(i.Amount) AS Amount
|
||||
FROM Vouchers v
|
||||
INNER JOIN Inventory i ON v.VoucherID = i.VoucherID
|
||||
WHERE v.LastEditDate BETWEEN @StartDate AND @FinishDate
|
||||
GROUP BY s.PaidStatus
|
||||
ORDER BY s.PaidStatus
|
||||
GROUP BY v.PaidStatus
|
||||
ORDER BY v.PaidStatus
|
||||
";
|
||||
cmd.CommandText = query;
|
||||
cmd.Parameters.AddWithValue("@StartDate", startDate);
|
||||
@@ -263,10 +255,10 @@ ORDER BY s.PaidStatus
|
||||
public decimal GetDetail(PaidStatus paidStatus, DateTime startDate, DateTime finishDate)
|
||||
{
|
||||
const string query = @"
|
||||
SELECT SUM(i.Amount) AS Amount, SUM(i.Quantity * i.Rate * i.Discount) AS Discount FROM Vouchers t INNER JOIN SaleVoucher s ON t.VoucherID = s.VoucherID
|
||||
INNER JOIN Inventory i ON t.VoucherID = i.VoucherID
|
||||
WHERE t.LastEditDate BETWEEN @StartDate AND @FinishDate
|
||||
AND s.PaidStatus = @PaidStatus
|
||||
SELECT SUM(i.Amount) AS Amount, SUM(i.Quantity * i.Rate * i.Discount) AS Discount FROM Vouchers v
|
||||
INNER JOIN Inventory i ON v.VoucherID = i.VoucherID
|
||||
WHERE v.LastEditDate BETWEEN @StartDate AND @FinishDate
|
||||
AND v.PaidStatus = @PaidStatus
|
||||
";
|
||||
using (var cmd = new SqlCommand(query))
|
||||
{
|
||||
|
||||
@@ -72,8 +72,6 @@
|
||||
<Compile Include="ProductDAO.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="SalesAnalysisDAO.cs" />
|
||||
<Compile Include="SaleVoucherMixDAO.cs" />
|
||||
<Compile Include="SaleVoucherDAO.cs" />
|
||||
<Compile Include="UserDAO.cs" />
|
||||
<Compile Include="VoucherDAO.cs" />
|
||||
</ItemGroup>
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
using System.Data.SqlClient;
|
||||
using Tanshu.Accounts.Contracts;
|
||||
using Tanshu.Data.DAO;
|
||||
using System.Collections.Generic;
|
||||
|
||||
|
||||
namespace Tanshu.Accounts.SqlDAO
|
||||
@@ -14,42 +15,78 @@ namespace Tanshu.Accounts.SqlDAO
|
||||
|
||||
public bool Insert(VoucherBO voucher)
|
||||
{
|
||||
using (SqlCommand cmd = new SqlCommand(@"
|
||||
SELECT @Code = ISNULL(MAX(Code), 0) + 1 FROM Vouchers;
|
||||
|
||||
using (var cmd = new SqlCommand(@"
|
||||
SELECT @VoucherID = NEWID(),
|
||||
@CreationDate = GETDATE(),
|
||||
@LastEditDate = GETDATE(),
|
||||
@Date = COALESCE(@Date, GETDATE());
|
||||
|
||||
INSERT INTO [Vouchers] ([VoucherID], [Code], [Date], [Narration], [UserID], [CreationDate], [LastEditDate])
|
||||
VALUES (@VoucherID, @Code, @Date, @Narration, @UserID, @CreationDate, @LastEditDate);
|
||||
SELECT @KotID = ISNULL('K-' + CAST(MAX(CAST(SUBSTRING(KotID, 3,8) AS int)) + 1 AS nvarchar(8)), 'K-1') FROM Vouchers
|
||||
IF @Printed = 1
|
||||
BEGIN
|
||||
SELECT @BillID = ISNULL(CAST(MAX(CAST(REPLACE(BillID, '-', '') AS int)) + 1 AS nvarchar(9)), '010001') FROM Vouchers WHERE BillID LIKE '__-____'
|
||||
IF LEN(@BillID) = 5
|
||||
SET @BillID = '0' + @BillID
|
||||
SET @BillID = SUBSTRING(@BillID, 1, 2) + '-' + SUBSTRING(@BillID, 3, 7)
|
||||
IF SUBSTRING(@BillID,3,7) = '-0000'
|
||||
SET @BillID = SUBSTRING(@BillID, 1, 2) + '-0001'
|
||||
END
|
||||
ELSE
|
||||
BEGIN
|
||||
SET @BillID = @KotID
|
||||
END
|
||||
IF @TableID = ''
|
||||
BEGIN
|
||||
SELECT @TableID = 'C' + CAST(ISNULL(MAX(CAST(SUBSTRING(TableID, 2, 10) AS int)), 0) + 1 AS nvarchar(10)) FROM Vouchers WHERE TableID LIKE 'C%' AND PaidStatus = 1
|
||||
END
|
||||
|
||||
INSERT INTO Vouchers (VoucherID, Date, Narration, UserID, CreationDate, LastEditDate, Floor, BillID, TableID, WaiterID, CustomerID, AdvanceID, PaidStatus, VoidReason, Printed, Alarm, KotID)
|
||||
VALUES (@VoucherID, @Date, @Narration, @UserID, @CreationDate, @LastEditDate, @Floor, @BillID, @TableID, @WaiterID, @CustomerID, @AdvanceID, @PaidStatus, @VoidReason, @Printed, @Alarm, @KotID)
|
||||
"))
|
||||
{
|
||||
cmd.Parameters.Add("@VoucherID", System.Data.SqlDbType.UniqueIdentifier);
|
||||
cmd.Parameters["@VoucherID"].Direction = System.Data.ParameterDirection.Output;
|
||||
cmd.Parameters.Add("@Code", System.Data.SqlDbType.Int);
|
||||
cmd.Parameters["@Code"].Direction = System.Data.ParameterDirection.Output;
|
||||
|
||||
cmd.Parameters.Add("@Date", System.Data.SqlDbType.DateTime);
|
||||
if (voucher.Date.HasValue)
|
||||
cmd.Parameters["@Date"].Value = voucher.Date.Value;
|
||||
else
|
||||
cmd.Parameters["@Date"].Value = DBNull.Value;
|
||||
cmd.Parameters["@Date"].Direction = System.Data.ParameterDirection.InputOutput;
|
||||
|
||||
cmd.Parameters.AddWithValue("@Narration", voucher.Narration);
|
||||
cmd.Parameters.AddWithValue("@UserID", voucher.UserID);
|
||||
cmd.Parameters.Add("@CreationDate", System.Data.SqlDbType.DateTime);
|
||||
cmd.Parameters["@CreationDate"].Direction = System.Data.ParameterDirection.Output;
|
||||
cmd.Parameters.Add("@LastEditDate", System.Data.SqlDbType.DateTime);
|
||||
cmd.Parameters["@LastEditDate"].Direction = System.Data.ParameterDirection.Output;
|
||||
|
||||
cmd.Parameters.AddWithValue("@Floor", voucher.Floor);
|
||||
cmd.Parameters.Add("@BillID", System.Data.SqlDbType.NVarChar, 10);
|
||||
cmd.Parameters["@BillID"].Direction = System.Data.ParameterDirection.Output;
|
||||
cmd.Parameters.AddWithValue("@TableID", voucher.TableID);
|
||||
cmd.Parameters.AddWithValue("@WaiterID", voucher.WaiterID);
|
||||
cmd.Parameters.AddWithValue("@CustomerID", voucher.CustomerID);
|
||||
if (voucher.AdvanceID.HasValue)
|
||||
cmd.Parameters.AddWithValue("@AdvanceID", voucher.AdvanceID);
|
||||
else
|
||||
cmd.Parameters.AddWithValue("@AdvanceID", DBNull.Value);
|
||||
cmd.Parameters.AddWithValue("@PaidStatus", (int)voucher.PaidStatus);
|
||||
if (voucher.VoidReason == null)
|
||||
voucher.VoidReason = string.Empty;
|
||||
cmd.Parameters.AddWithValue("@VoidReason", voucher.VoidReason);
|
||||
cmd.Parameters.AddWithValue("@Printed", voucher.Printed);
|
||||
if (voucher.Alarm.HasValue)
|
||||
cmd.Parameters.AddWithValue("@Alarm", voucher.Alarm);
|
||||
else
|
||||
cmd.Parameters.AddWithValue("@Alarm", DBNull.Value);
|
||||
cmd.Parameters.Add("@KotID", System.Data.SqlDbType.NVarChar, 10);
|
||||
cmd.Parameters["@KotID"].Direction = System.Data.ParameterDirection.Output;
|
||||
connection.ExecuteNonQuery(cmd);
|
||||
voucher.VoucherID = (Guid)cmd.Parameters["@VoucherID"].Value;
|
||||
voucher.Code = (int)cmd.Parameters["@Code"].Value;
|
||||
voucher.CreationDate = (DateTime)cmd.Parameters["@CreationDate"].Value;
|
||||
voucher.LastEditDate = (DateTime)cmd.Parameters["@LastEditDate"].Value;
|
||||
voucher.Date = (DateTime)cmd.Parameters["@Date"].Value;
|
||||
voucher.BillID = (string)cmd.Parameters["@BillID"].Value;
|
||||
voucher.KotID = (string)cmd.Parameters["@KotID"].Value;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -59,6 +96,12 @@ namespace Tanshu.Accounts.SqlDAO
|
||||
cmd.Parameters.AddWithValue("@VoucherID", voucherID);
|
||||
return BusinessObjectDAO<VoucherBO>.GetBusinessObject(connection.ExecuteReader(cmd));
|
||||
}
|
||||
public VoucherBO GetVoucher(string billID)
|
||||
{
|
||||
SqlCommand cmd = new SqlCommand("SELECT * FROM Vouchers WHERE BillID = @BillID");
|
||||
cmd.Parameters.AddWithValue("@BillID", billID);
|
||||
return BusinessObjectDAO<VoucherBO>.GetBusinessObject(connection.ExecuteReader(cmd));
|
||||
}
|
||||
public bool Delete(Guid voucherID)
|
||||
{
|
||||
using (SqlCommand cmd = new SqlCommand("DELETE from Vouchers where VoucherID = @VoucherID"))
|
||||
@@ -70,46 +113,239 @@ namespace Tanshu.Accounts.SqlDAO
|
||||
}
|
||||
public bool Update(VoucherBO voucher)
|
||||
{
|
||||
using (SqlCommand cmd = new SqlCommand(@"
|
||||
SELECT @LastEditDate = GETDATE(),
|
||||
@Date = COALESCE(@Date, GETDATE())
|
||||
using (var cmd = new SqlCommand(@"
|
||||
SELECT @CreationDate = CreationDate, @LastEditDate = GETDATE(), @Date = COALESCE(@Date, GETDATE()), @KotID = KotID
|
||||
FROM Vouchers
|
||||
WHERE VoucherID = @VoucherID;
|
||||
|
||||
UPDATE [Vouchers]
|
||||
SET [Date] = @Date,
|
||||
IF @Printed = 1 AND (SELECT Printed FROM Vouchers WHERE VoucherID = @VoucherID) = 0
|
||||
BEGIN
|
||||
SELECT @BillID = ISNULL(CAST(MAX(CAST(REPLACE(BillID, '-', '') AS int)) + 1 AS nvarchar(9)), '010001') FROM Vouchers WHERE BillID LIKE '__-____'
|
||||
IF LEN(@BillID) = 5
|
||||
SET @BillID = '0' + @BillID
|
||||
SET @BillID = SUBSTRING(@BillID, 1, 2) + '-' + SUBSTRING(@BillID, 3, 7)
|
||||
IF SUBSTRING(@BillID,3,7) = '-0000'
|
||||
SET @BillID = SUBSTRING(@BillID, 1, 2) + '-0001'
|
||||
END
|
||||
ELSE
|
||||
BEGIN
|
||||
SELECT @BillID = BillID FROM Vouchers WHERE VoucherID = @VoucherID
|
||||
END
|
||||
IF @TableID = ''
|
||||
BEGIN
|
||||
SELECT @TableID = 'C' + CAST(ISNULL(MAX(CAST(SUBSTRING(TableID, 2, 10) AS int)), 0) + 1 AS nvarchar(10)) FROM Vouchers WHERE TableID LIKE 'C%' AND PaidStatus = 1
|
||||
END
|
||||
IF (SELECT Printed FROM Vouchers WHERE VoucherID = @VoucherID) = 1
|
||||
SET @Printed = 1
|
||||
UPDATE [Vouchers] SET
|
||||
[Date] = @Date,
|
||||
[Narration] = @Narration,
|
||||
[UserID] = @UserID,
|
||||
[LastEditDate] = @LastEditDate
|
||||
WHERE [VoucherID] = @VoucherID
|
||||
|
||||
SELECT @Code = Code, @CreationDate = CreationDate
|
||||
FROM [Vouchers]
|
||||
WHERE [VoucherID] = @VoucherID
|
||||
[LastEditDate] = @LastEditDate,
|
||||
[Floor] = @Floor,
|
||||
[BillID] = @BillID,
|
||||
[TableID] = @TableID,
|
||||
[WaiterID] = @WaiterID,
|
||||
[CustomerID] = @CustomerID,
|
||||
[AdvanceID] = @AdvanceID,
|
||||
[PaidStatus] = @PaidStatus,
|
||||
[VoidReason] = @VoidReason,
|
||||
[Printed] = @Printed,
|
||||
[Alarm] = @Alarm
|
||||
WHERE VoucherID = @VoucherID;
|
||||
"))
|
||||
{
|
||||
cmd.Parameters.AddWithValue("@VoucherID", voucher.VoucherID);
|
||||
cmd.Parameters.AddWithValue("@Code", voucher.Code);
|
||||
cmd.Parameters["@Code"].Direction = System.Data.ParameterDirection.Output;
|
||||
|
||||
cmd.Parameters.Add("@Date", System.Data.SqlDbType.DateTime);
|
||||
if (voucher.Date.HasValue)
|
||||
cmd.Parameters["@Date"].Value = voucher.Date.Value;
|
||||
else
|
||||
cmd.Parameters["@Date"].Value = DBNull.Value;
|
||||
cmd.Parameters["@Date"].Direction = System.Data.ParameterDirection.InputOutput;
|
||||
|
||||
cmd.Parameters.AddWithValue("@Narration", voucher.Narration);
|
||||
cmd.Parameters.AddWithValue("@UserID", voucher.UserID);
|
||||
cmd.Parameters.Add("@CreationDate", System.Data.SqlDbType.DateTime);
|
||||
cmd.Parameters["@CreationDate"].Direction = System.Data.ParameterDirection.Output;
|
||||
cmd.Parameters.Add("@LastEditDate", System.Data.SqlDbType.DateTime);
|
||||
cmd.Parameters["@LastEditDate"].Direction = System.Data.ParameterDirection.Output;
|
||||
|
||||
cmd.Parameters.Add("@BillID", System.Data.SqlDbType.NVarChar, 10);
|
||||
cmd.Parameters["@BillID"].Direction = System.Data.ParameterDirection.Output;
|
||||
cmd.Parameters.AddWithValue("@Floor", voucher.Floor);
|
||||
cmd.Parameters.AddWithValue("@TableID", voucher.TableID);
|
||||
cmd.Parameters.AddWithValue("@WaiterID", voucher.WaiterID);
|
||||
cmd.Parameters.AddWithValue("@CustomerID", voucher.CustomerID);
|
||||
if (voucher.AdvanceID.HasValue)
|
||||
cmd.Parameters.AddWithValue("@AdvanceID", voucher.AdvanceID);
|
||||
else
|
||||
cmd.Parameters.AddWithValue("@AdvanceID", DBNull.Value);
|
||||
cmd.Parameters.AddWithValue("@PaidStatus", voucher.PaidStatus);
|
||||
if (voucher.VoidReason == null)
|
||||
voucher.VoidReason = string.Empty;
|
||||
cmd.Parameters.AddWithValue("@VoidReason", voucher.VoidReason);
|
||||
cmd.Parameters.AddWithValue("@Printed", voucher.Printed);
|
||||
if (voucher.Alarm.HasValue)
|
||||
cmd.Parameters.AddWithValue("@Alarm", voucher.Alarm);
|
||||
else
|
||||
cmd.Parameters.AddWithValue("@Alarm", DBNull.Value);
|
||||
cmd.Parameters.Add("@KotID", System.Data.SqlDbType.NVarChar, 10);
|
||||
cmd.Parameters["@KotID"].Direction = System.Data.ParameterDirection.Output;
|
||||
connection.ExecuteNonQuery(cmd);
|
||||
voucher.Code = (int)cmd.Parameters["@Code"].Value;
|
||||
voucher.BillID = (string)cmd.Parameters["@BillID"].Value;
|
||||
voucher.KotID = (string)cmd.Parameters["@KotID"].Value;
|
||||
voucher.CreationDate = (DateTime)cmd.Parameters["@CreationDate"].Value;
|
||||
voucher.LastEditDate = (DateTime)cmd.Parameters["@LastEditDate"].Value;
|
||||
voucher.Date = (DateTime)cmd.Parameters["@Date"].Value;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
public void SetAlarm(Guid voucherID, DateTime? alarmTime)
|
||||
{
|
||||
using (var cmd = new SqlCommand(@"UPDATE Vouchers SET Alarm = @Alarm WHERE VoucherID = @VoucherID"))
|
||||
{
|
||||
cmd.Parameters.AddWithValue("@VoucherID", voucherID);
|
||||
cmd.Parameters.AddWithValue("@Alarm", alarmTime);
|
||||
connection.ExecuteNonQuery(cmd);
|
||||
}
|
||||
}
|
||||
public void VoidBill(Guid voucherID, string reason, Guid userID)
|
||||
{
|
||||
using (SqlCommand cmd = new SqlCommand(@"UPDATE Vouchers SET PaidStatus = @PaidStatus, VoidReason = @VoidReason WHERE VoucherID = @VoucherID; UPDATE Vouchers SET UserID = @UserID, LastEditDate = GETDATE() WHERE VoucherID = @VoucherID"))
|
||||
{
|
||||
cmd.Parameters.AddWithValue("@VoucherID", voucherID);
|
||||
cmd.Parameters.AddWithValue("@UserID", userID);
|
||||
cmd.Parameters.AddWithValue("@PaidStatus", (int)PaidStatus.Void);
|
||||
cmd.Parameters.AddWithValue("@VoidReason", reason);
|
||||
connection.ExecuteNonQuery(cmd);
|
||||
}
|
||||
}
|
||||
|
||||
public List<PendingBillsBO> GetPendingBills(PendingType list, int floor)
|
||||
{
|
||||
var query = @"
|
||||
SELECT v.VoucherID, v.Alarm AS Alarm, v.TableID AS TableID,
|
||||
(SELECT SUM(Amount) FROM Inventory WHERE VoucherID = v.VoucherID) AS Amount,
|
||||
v.BillID, v.CreationDate, u.Name, CAST(0 AS bit), v.KotID, v.LastEditDate, v.Printed, v.AdvanceID
|
||||
FROM Vouchers v INNER JOIN Users u ON v.UserID = u.UserID
|
||||
WHERE v.PaidStatus = @PaidStatus
|
||||
";
|
||||
if (list == PendingType.Alarms)
|
||||
query += "AND v.Alarm IS NOT NULL ";
|
||||
else
|
||||
query += "AND v.Alarm IS NULL ";
|
||||
if (floor != 0)
|
||||
query += "AND v.Floor = @Floor ";
|
||||
if (list == PendingType.Today)
|
||||
query += string.Format("AND v.LastEditDate >= '{0:dd-MMM-yyyy} 00:00:00' ", DateTime.Now);
|
||||
else if (list == PendingType.Week)
|
||||
query += string.Format("AND v.LastEditDate >= '{0:dd-MMM-yyyy} 00:00:00' ", DateTime.Now.AddDays(-7));
|
||||
query += "ORDER BY v.CreationDate ";
|
||||
using (var cmd = new SqlCommand(query))
|
||||
{
|
||||
cmd.Parameters.AddWithValue("@PaidStatus", (int)PaidStatus.Pending);
|
||||
if (floor != 0)
|
||||
cmd.Parameters.AddWithValue("@Floor", floor);
|
||||
using (var dr = connection.ExecuteReader(cmd))
|
||||
{
|
||||
var outList = new List<PendingBillsBO>();
|
||||
while (dr.Read())
|
||||
{
|
||||
var local = new PendingBillsBO();
|
||||
local.voucherID = dr.GetGuid(0);
|
||||
local.Alarm = !dr.IsDBNull(1);
|
||||
if (local.Alarm)
|
||||
local.AlarmTime = dr.GetDateTime(1);
|
||||
local.TableID = dr.GetString(2);
|
||||
if (!dr.IsDBNull(3))
|
||||
local.Amount = dr.GetDecimal(3);
|
||||
local.BillNo = dr.GetString(4);
|
||||
local.BookingTime = dr.GetDateTime(5);
|
||||
local.Cashier = dr.GetString(6);
|
||||
local.Important = dr.GetBoolean(7);
|
||||
local.Kot = dr.GetString(8);
|
||||
local.LastEdited = dr.GetDateTime(9);
|
||||
local.Printed = dr.GetBoolean(10);
|
||||
if (!dr.IsDBNull(11))
|
||||
local.AdvanceID = dr.GetGuid(11);
|
||||
outList.Add(local);
|
||||
}
|
||||
return outList;
|
||||
}
|
||||
}
|
||||
}
|
||||
public Guid? GetPendingVoucherID(string tableID, int floor)
|
||||
{
|
||||
var query = "SELECT VoucherID FROM Vouchers where TableID = @TableID and PaidStatus = @PaidStatus";
|
||||
if (floor != 0)
|
||||
query += " AND Floor = @Floor ";
|
||||
using (var cmd = new SqlCommand(query))
|
||||
{
|
||||
cmd.Parameters.AddWithValue("@TableID", tableID);
|
||||
cmd.Parameters.AddWithValue("@PaidStatus", (int)PaidStatus.Pending);
|
||||
if (floor != 0)
|
||||
cmd.Parameters.AddWithValue("@Floor", floor);
|
||||
using (var dr = connection.ExecuteReader(cmd))
|
||||
{
|
||||
if (dr.Read())
|
||||
{
|
||||
return dr.GetGuid(0);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
private class BillPaidClass
|
||||
{
|
||||
public Guid VoucherID { get; set; }
|
||||
public string KotID { get; set; }
|
||||
public bool Printed { get; set; }
|
||||
}
|
||||
public void DeclareBillsPaid(Guid userID, List<Guid> billList, PaidStatus paidStatus)
|
||||
{
|
||||
if (billList.Count == 0)
|
||||
return;
|
||||
var removeItems = new List<Guid>();
|
||||
var query = "SELECT VoucherID, KotID, Printed FROM Vouchers WHERE VoucherID IN (";
|
||||
foreach (var voucherID in billList)
|
||||
{
|
||||
query += string.Format("'{0}', ", voucherID);
|
||||
}
|
||||
query = query.Substring(0, query.Length - 2) + ")";
|
||||
|
||||
var pbc = new List<BillPaidClass>();
|
||||
using (var cmd = new SqlCommand(query))
|
||||
{
|
||||
using (var dr = connection.ExecuteReader(cmd))
|
||||
{
|
||||
while (dr.Read())
|
||||
{
|
||||
pbc.Add(new BillPaidClass
|
||||
{
|
||||
VoucherID = dr.GetGuid(0),
|
||||
KotID = dr.GetString(1),
|
||||
Printed = dr.GetBoolean(2)
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
foreach (var item in pbc)
|
||||
{
|
||||
if (!item.Printed)
|
||||
continue;
|
||||
using (var cmd = new SqlCommand(@"
|
||||
UPDATE Vouchers SET PaidStatus = @PaidStatus, UserID = @UserID, LastEditDate = GETDATE() WHERE VoucherID = @VoucherID;
|
||||
"))
|
||||
{
|
||||
cmd.Parameters.AddWithValue("@VoucherID", item.VoucherID);
|
||||
cmd.Parameters.AddWithValue("@UserID", userID);
|
||||
cmd.Parameters.AddWithValue("@PaidStatus", (int)paidStatus);
|
||||
connection.ExecuteNonQuery(cmd);
|
||||
}
|
||||
removeItems.Add(item.VoucherID);
|
||||
}
|
||||
|
||||
foreach (var item in removeItems)
|
||||
billList.Remove(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -47,7 +47,7 @@ UPDATE Waiters SET Name = @Name, Code = @Code WHERE WaiterID = @WaiterID;
|
||||
public bool Delete(Guid waiterID)
|
||||
{
|
||||
bool result;
|
||||
using (SqlCommand cmd = new SqlCommand("SELECT Count(*) FROM SaleVoucher WHERE WaiterID = @WaiterID"))
|
||||
using (SqlCommand cmd = new SqlCommand("SELECT Count(*) FROM Voucher WHERE WaiterID = @WaiterID"))
|
||||
{
|
||||
cmd.Parameters.AddWithValue("@WaiterID", waiterID);
|
||||
result = 0 == (int)connection.ExecuteScalar(cmd);
|
||||
|
||||
Reference in new issue
Block a user