Feature: Added service tax and changed around a lot of SQL structure. Run the conversion sql file or it won't work.

This commit is contained in:
Amritanshu committed 2013-11-28 16:09:33 +05:30
1 parent b6498a7b1c
commit c36240398f
92 files changed
+434 -1798

No files matched your search

+58
View File
@@ -0,0 +1,58 @@
BEGIN TRANSACTION
ALTER TABLE dbo.Inventory DROP CONSTRAINT FK_Inventory_Products;
ALTER TABLE dbo.Inventory DROP CONSTRAINT FK_Inventory_Vouchers;
ALTER TABLE dbo.Inventory DROP CONSTRAINT DF_Inventory_Discount;
CREATE TABLE dbo.Tmp_Inventory (
InventoryID uniqueidentifier NOT NULL,
VoucherID uniqueidentifier NOT NULL,
ProductID uniqueidentifier NOT NULL,
Quantity decimal(18, 5) NOT NULL,
Rate decimal(18, 5) NOT NULL,
Vat decimal(18, 5) NOT NULL,
ServiceTax decimal(18, 5) NOT NULL,
Discount decimal(18, 5) NOT NULL,
Amount AS ((([Quantity]*[Rate])*((1)+[ServiceTax]+[Vat]))*((1)-[Discount]))
);
ALTER TABLE dbo.Tmp_Inventory ADD CONSTRAINT DF_Inventory_Discount DEFAULT ((0)) FOR Discount;
IF EXISTS(SELECT * FROM dbo.Inventory)
EXEC('INSERT INTO dbo.Tmp_Inventory (InventoryID, VoucherID, ProductID, Quantity, Rate, Vat, ServiceTax, Discount)
SELECT InventoryID, VoucherID, ProductID, Quantity, Rate, Tax, 0, Discount FROM dbo.Inventory WITH (HOLDLOCK TABLOCKX)');
DROP TABLE dbo.Inventory;
EXECUTE sp_rename N'dbo.Tmp_Inventory', N'Inventory', 'OBJECT';
ALTER TABLE dbo.Inventory ADD CONSTRAINT PK_Inventory PRIMARY KEY CLUSTERED (InventoryID);
ALTER TABLE dbo.Inventory ADD CONSTRAINT FK_Inventory_Vouchers FOREIGN KEY (VoucherID) REFERENCES dbo.Vouchers (VoucherID);
ALTER TABLE dbo.Inventory ADD CONSTRAINT FK_Inventory_Products FOREIGN KEY (ProductID) REFERENCES dbo.Products (ProductID);
ALTER TABLE dbo.Vouchers DROP CONSTRAINT IX_Vouchers_Code_Type;
ALTER TABLE dbo.Vouchers ADD CONSTRAINT IX_Vouchers_Code UNIQUE NONCLUSTERED (Code);
ALTER TABLE dbo.Ledgers DROP CONSTRAINT FK_Ledgers_CostCenters;
ALTER TABLE dbo.Products DROP CONSTRAINT FK_Products_Ledgers_Sale;
ALTER TABLE dbo.Products DROP CONSTRAINT FK_Products_Ledgers_Purchase;
ALTER TABLE dbo.ComplexProducts DROP CONSTRAINT FK_ComplexProducts_Products;
ALTER TABLE dbo.Customers DROP CONSTRAINT FK_Customers_Ledgers;
DROP TABLE dbo.ComplexProducts;
ALTER TABLE dbo.Products DROP COLUMN timestamp;
ALTER TABLE dbo.Products DROP COLUMN PurchasePrice;
ALTER TABLE dbo.Products DROP COLUMN SaleLedgerID;
ALTER TABLE dbo.Products DROP COLUMN PurchaseLedgerID;
ALTER TABLE dbo.Waiters DROP COLUMN timestamp;
ALTER TABLE dbo.Vouchers DROP COLUMN Ref;
ALTER TABLE dbo.Vouchers DROP COLUMN Type;
ALTER TABLE dbo.Vouchers DROP COLUMN timestamp;
ALTER TABLE dbo.SaleVoucher DROP COLUMN timestamp;
ALTER TABLE dbo.Users DROP COLUMN timestamp;
ALTER TABLE dbo.Customers DROP COLUMN LedgerID;
ALTER TABLE dbo.Customers DROP COLUMN timestamp;
ALTER TABLE dbo.ProductTypes DROP COLUMN timestamp;
ALTER TABLE dbo.Roles DROP COLUMN timestamp;
ALTER TABLE dbo.Tax DROP COLUMN timestamp;
ALTER TABLE dbo.UserRoles DROP COLUMN timestamp;
DROP TABLE CostCenters;
DROP TABLE Ledgers;
exec sp_rename 'dbo.ProductTypes', 'ProductGroups';
exec sp_rename 'dbo.ProductGroups.ProductTypeID', 'ProductGroupID', 'COLUMN';
exec sp_rename 'dbo.Products.ProductTypeID', 'ProductGroupID', 'COLUMN';
exec sp_rename 'dbo.Products.PurchaseTaxID', 'ServiceTaxID', 'COLUMN';
exec sp_rename 'dbo.Products.SaleTaxID', 'VatID', 'COLUMN';
COMMIT
-- ROLLBACK
+1 -2
View File
@@ -5,11 +5,10 @@ using Tanshu.Accounts.Contracts;
namespace Tanshu.Accounts.BI
{
public class AdvanceBI : IAdvanceBI
public class AdvanceBI
{
public void Insert(AdvanceBO advance)
{
using (var connection = new SqlDAO.SqlConnectionDAO())
{
using (var dao = new SqlDAO.AdvanceDAO(connection))
+1 -13
View File
@@ -4,20 +4,8 @@ using Tanshu.Accounts.Contracts;
namespace Tanshu.Accounts.BI
{
public class CustomerBI : ICustomerBI
public class CustomerBI
{
public List<LedgerBO> GetCustomerLedgers()
{
using (var connection = new SqlDAO.SqlConnectionDAO())
{
using (var dao = new SqlDAO.CustomerDAO(connection))
{
return dao.GetCustomerLedgers();
}
}
}
public CustomerBO GetCustomer(Guid customerID)
{
-76
View File
@@ -1,76 +0,0 @@
using System;
using System.Collections.Generic;
using Tanshu.Accounts.Contracts;
namespace Tanshu.Accounts.BI
{
public class LedgerBI : ILedgerBI
{
public LedgerBO GetLedger(Guid ledgerID)
{
using (var connection = new SqlDAO.SqlConnectionDAO())
{
using (var dao = new SqlDAO.LedgerDAO(connection))
{
return dao.GetLedger(ledgerID);
}
}
}
public LedgerBO GetLedgerByName(string name)
{
using (var connection = new SqlDAO.SqlConnectionDAO())
{
using (var dao = new SqlDAO.LedgerDAO(connection))
{
return dao.GetLedger(name);
}
}
}
public bool Insert(LedgerBO ledger)
{
using (var connection = new SqlDAO.SqlConnectionDAO())
{
using (var dao = new SqlDAO.LedgerDAO(connection))
{
return dao.Insert(ledger);
}
}
}
public bool Update(LedgerBO ledger)
{
using (var connection = new SqlDAO.SqlConnectionDAO())
{
using (var dao = new SqlDAO.LedgerDAO(connection))
{
return dao.Update(ledger);
}
}
}
public List<LedgerDisplayBO> GetLedgers()
{
using (var connection = new SqlDAO.SqlConnectionDAO())
{
using (var dao = new SqlDAO.LedgerDAO(connection))
{
return dao.GetLedgers();
}
}
}
public List<LedgerDisplayBO> GetLedgersOfType(char type)
{
using (var connection = new SqlDAO.SqlConnectionDAO())
{
using (var dao = new SqlDAO.LedgerDAO(connection))
{
return dao.GetLedgers(type);
}
}
}
}
}
+1 -1
View File
@@ -3,7 +3,7 @@ using Tanshu.Accounts.Contracts;
namespace Tanshu.Accounts.BI
{
public class MembershipBI : IMembershipBI
public class MembershipBI
{
public bool ValidateUser(string name, string password)
{
+1 -1
View File
@@ -4,7 +4,7 @@ using Tanshu.Accounts.Contracts;
namespace Tanshu.Accounts.BI
{
public class PaymentBI : IPaymentBI
public class PaymentBI
{
public void Insert(PaymentBO payment)
{
+15 -15
View File
@@ -4,7 +4,7 @@ using Tanshu.Accounts.Contracts;
namespace Tanshu.Accounts.BI
{
public class ProductBI : IProductBI
public class ProductBI
{
public bool Insert(ProductBO product)
{
@@ -61,17 +61,6 @@ namespace Tanshu.Accounts.BI
}
}
}
public decimal GetProductStock(DateTime date, Guid productID, Guid? voucherID)
{
using (var connection = new SqlDAO.SqlConnectionDAO())
{
using (var dao = new SqlDAO.ProductDAO(connection))
{
return dao.GetProductStock(date, productID, voucherID);
}
}
}
public List<ProductDisplayBO> GetProducts()
{
@@ -115,14 +104,25 @@ namespace Tanshu.Accounts.BI
filter.Add("Type", "");
return GetFilteredProducts(filter);
}
public List<ProductTypeBO> GetProductTypes()
public List<ProductGroupBO> GetProductGroups()
{
using (var connection = new SqlDAO.SqlConnectionDAO())
{
using (var dao = new SqlDAO.ProductDAO(connection))
{
return dao.GetProductTypes();
return dao.GetProductGroups();
}
}
}
public List<TaxBO> GetTaxes()
{
using (var connection = new SqlDAO.SqlConnectionDAO())
{
using (var dao = new SqlDAO.ProductDAO(connection))
{
return dao.GetTaxes();
}
}
}
+1 -1
View File
@@ -4,7 +4,7 @@ using Tanshu.Accounts.Contracts;
namespace Tanshu.Accounts.BI
{
public class SaleVoucherBI : ISaleVoucherBI
public class SaleVoucherBI
{
public SalesBillItemBO GetDefaultSaleBillItem(Guid productID)
{
+5 -5
View File
@@ -4,16 +4,16 @@ using Tanshu.Accounts.Contracts;
namespace Tanshu.Accounts.BI
{
public class SalesAnalysisBI : ISalesAnalysisBI
public class SalesAnalysisBI
{
public List<SalesAnalysisDetailBO> GetSaleDetail(DateTime startDate, DateTime finishDate, Guid costCenterID)
public List<SalesAnalysisDetailBO> GetSaleDetail(DateTime startDate, DateTime finishDate, Guid productGroupID)
{
using (var connection = new SqlDAO.SqlConnectionDAO())
{
using (var dao = new SqlDAO.SalesAnalysisDAO(connection))
{
return dao.GetSaleDetail(startDate, finishDate, costCenterID);
return dao.GetSaleDetail(startDate, finishDate, productGroupID);
}
}
}
@@ -29,14 +29,14 @@ namespace Tanshu.Accounts.BI
}
}
}
public void GetAdditionalInfo(ref decimal freeSale, ref decimal voids, ref decimal pending, ref decimal net, ref decimal tax, DateTime startDate, DateTime finishDate)
public decimal GetFreeSale(DateTime startDate, DateTime finishDate)
{
using (var connection = new SqlDAO.SqlConnectionDAO())
{
using (var dao = new SqlDAO.SalesAnalysisDAO(connection))
{
dao.GetAdditionalInfo(ref freeSale, ref voids, ref pending, ref net, ref tax, startDate, finishDate);
return dao.GetFreeSale(startDate, finishDate);
}
}
}
@@ -69,7 +69,6 @@
<Compile Include="RoleBI.cs" />
<Compile Include="SecurityBI.cs" />
<Compile Include="WaiterBI.cs" />
<Compile Include="LedgerBI.cs" />
<Compile Include="MembershipBI.cs" />
<Compile Include="PaymentBI.cs" />
<Compile Include="ProductBI.cs" />
+1 -1
View File
@@ -4,7 +4,7 @@ using Tanshu.Accounts.Contracts;
namespace Tanshu.Accounts.BI
{
public class UserBI : IUserBI
public class UserBI
{
public UserBO GetUser(Guid userID)
{
+1 -1
View File
@@ -4,7 +4,7 @@ using Tanshu.Accounts.Contracts;
namespace Tanshu.Accounts.BI
{
public class WaiterBI : IWaiterBI
public class WaiterBI
{
public bool Insert(WaiterBO waiter)
{
@@ -3,22 +3,14 @@ using System.Runtime.Serialization;
namespace Tanshu.Accounts.Contracts
{
[DataContract]
public class AdvanceBO
{
[DataMember]
public Guid AdvanceID { get; set; }
[DataMember]
public decimal Amount { get; set; }
[DataMember]
public string Narration { get; set; }
[DataMember]
public Guid CashierIn { get; set; }
[DataMember]
public DateTime DateIn { get; set; }
[DataMember]
public Guid? CashierOut { get; set; }
[DataMember]
public DateTime? DateOut { get; set; }
}
}
@@ -3,10 +3,9 @@ using System.Runtime.Serialization;
namespace Tanshu.Accounts.Contracts
{
[DataContract]
public class AdvanceDisplayBO : AdvanceBO
{
[DataMember]
public string Cashier { get; set; }
public string UserOut { get; set; }
}
}
@@ -1,28 +0,0 @@
using System;
using System.Runtime.Serialization;
namespace Tanshu.Accounts.Contracts
{
[DataContract]
public class ComplexProductBO
{
[DataMember]
public Guid ComplexProductID { get; set; }
[DataMember]
public Guid ProductID { get; set; }
[DataMember]
public int Code { get; set; }
[DataMember]
public string Name { get; set; }
[DataMember]
public string Units { get; set; }
[DataMember]
public decimal SalePrice { get; set; }
[DataMember]
public Guid SaleTaxID { get; set; }
[DataMember]
public decimal Quantity { get; set; }
[DataMember]
public byte[] timestamp { get; set; }
}
}
@@ -1,18 +0,0 @@
using System;
using System.Runtime.Serialization;
namespace Tanshu.Accounts.Contracts
{
[DataContract]
public class CostCenterBO
{
[DataMember]
public Guid CostCenterID { get; set; }
[DataMember]
public int Code { get; set; }
[DataMember]
public string Name { get; set; }
[DataMember]
public byte[] timestamp { get; set; }
}
}
@@ -3,27 +3,22 @@ using System.Runtime.Serialization;
namespace Tanshu.Accounts.Contracts
{
[DataContract]
public class CustomerBO
{
[DataMember]
public Guid CustomerID { get; set; }
[DataMember]
public int Code { get; set; }
[DataMember]
public string Name { get; set; }
[DataMember]
public Guid LedgerID { get; set; }
[DataMember]
public string Address { get; set; }
[DataMember]
public bool Important { get; set; }
[DataMember]
public string Phone { get; set; }
[DataMember]
public string Remarks { get; set; }
[DataMember]
public byte[] timestamp { get; set; }
}
}
@@ -3,19 +3,17 @@ using System.Runtime.Serialization;
namespace Tanshu.Accounts.Contracts
{
[DataContract]
public class InventoryBO
{
[DataMember]
public Guid InventoryID { get; set; }
[DataMember]
public Guid VoucherID { get; set; }
[DataMember]
public Guid ProductID { get; set; }
[DataMember]
public Guid? ComplexProductID { get; set; }
private decimal quantity;
[DataMember]
public decimal Quantity
{
get { return quantity; }
@@ -27,7 +25,7 @@ namespace Tanshu.Accounts.Contracts
}
}
private decimal rate;
[DataMember]
public decimal Rate
{
get { return rate; }
@@ -38,20 +36,31 @@ namespace Tanshu.Accounts.Contracts
CalculateAmount();
}
}
decimal tax;
[DataMember]
public decimal Tax
decimal vat;
public decimal Vat
{
get { return tax; }
get { return vat; }
set
{
tax = value; if (amount != null)
vat = value; if (amount != null)
CalculateAmount();
}
}
decimal serviceTax;
public decimal ServiceTax
{
get { return serviceTax; }
set
{
serviceTax = value; if (amount != null)
CalculateAmount();
}
}
decimal discount;
[DataMember]
public decimal Discount
{
get { return discount; }
@@ -63,7 +72,7 @@ namespace Tanshu.Accounts.Contracts
}
decimal? amount;
[DataMember]
public decimal Amount
{
get
@@ -75,16 +84,7 @@ namespace Tanshu.Accounts.Contracts
}
private void CalculateAmount()
{
amount = quantity * rate * (1 + tax) * (1 - discount);
amount = quantity * rate * (1 + vat + serviceTax) * (1 - discount);
}
[DataMember]
public bool IsRateFinal { get; set; }
[DataMember]
public bool RateFinal
{
get { return IsRateFinal; }
}
[DataMember]
public byte[] timestamp { get; set; }
}
}
@@ -3,10 +3,10 @@ using System.Runtime.Serialization;
namespace Tanshu.Accounts.Contracts
{
[DataContract]
public class InventoryDisplayBO : InventoryBO
{
[DataMember]
public string ProductName { get; set; }
}
}
@@ -1,41 +0,0 @@
using System;
using System.Runtime.Serialization;
namespace Tanshu.Accounts.Contracts
{
[DataContract]
public class JournalBO
{
[DataMember]
public Guid JournalID { get; set; }
[DataMember]
public Guid VoucherID { get; set; }
[DataMember]
public Guid LedgerID { get; set; }
[DataMember]
public Guid CostCenterID { get; set; }
[DataMember]
public decimal Amount { get; set; }
private int debit;
[DataMember]
public int Debit
{
get { return debit; }
set
{
if ((value == 1) || (value == -1))
debit = value;
else
throw new ArgumentException("Debit can only be -1 or 1");
}
}
[DataMember]
public decimal SignedAmount
{
get { return Amount * Debit; }
}
[DataMember]
public byte[] timestamp { get; set; }
}
}
@@ -1,12 +0,0 @@
using System;
using System.Runtime.Serialization;
namespace Tanshu.Accounts.Contracts
{
[DataContract]
public class JournalDisplayBO : JournalBO
{
[DataMember]
public string LedgerName { get; set; }
}
}
@@ -1,26 +0,0 @@
using System;
using System.Runtime.Serialization;
namespace Tanshu.Accounts.Contracts
{
[DataContract]
public class LedgerBO
{
[DataMember]
public Guid LedgerID { get; set; }
[DataMember]
public int Code { get; set; }
[DataMember]
public string Name { get; set; }
[DataMember]
public virtual char Type { get; set; }
[DataMember]
public Guid ParentLedgerID { get; set; }
[DataMember]
public Guid CostCenterID { get; set; }
[DataMember]
public bool IsActive { get; set; }
[DataMember]
public byte[] timestamp { get; set; }
}
}
@@ -1,12 +0,0 @@
using System;
using System.Runtime.Serialization;
namespace Tanshu.Accounts.Contracts
{
[DataContract]
public class LedgerDisplayBO : LedgerBO
{
[DataMember]
public string CostCenter { get; set; }
}
}
@@ -1,20 +0,0 @@
using System;
using System.Runtime.Serialization;
namespace Tanshu.Accounts.Contracts
{
[DataContract]
public class LedgerTypeBO
{
[DataMember]
public char TypeID { get; set; }
[DataMember]
public string Name { get; set; }
[DataMember]
public int SortOrder { get; set; }
[DataMember]
public short Debit { get; set; }
[DataMember]
public byte Location { get; set; }
}
}
@@ -3,21 +3,14 @@ using System.Runtime.Serialization;
namespace Tanshu.Accounts.Contracts
{
[DataContract]
public class PaymentBO
{
[DataMember]
public Guid PaymentID { get; set; }
[DataMember]
public DateTime Date { get; set; }
[DataMember]
public string Type { get; set; }
[DataMember]
public Guid CashierID { get; set; }
[DataMember]
public decimal Amount { get; set; }
[DataMember]
public string Narration { get; set; }
}
}
@@ -3,10 +3,8 @@ using System.Runtime.Serialization;
namespace Tanshu.Accounts.Contracts
{
[DataContract]
public class PaymentDisplayBO : PaymentBO
{
[DataMember]
public string Cashier { get; set; }
}
}
@@ -1,34 +0,0 @@
using System;
using System.Runtime.Serialization;
namespace Tanshu.Accounts.Contracts
{
[DataContract]
public class PaymentSheetBO
{
[DataMember]
public Guid SalaryPaymentID { get; set; }
[DataMember]
public Guid LedgerID { get; set; }
[DataMember]
public Guid VoucherID { get; set; }
[DataMember]
public decimal Opening { get; set; }
[DataMember]
public decimal Salary { get; set; }
[DataMember]
public decimal Total
{
get { return Opening + Salary; }
}
[DataMember]
public int Paid { get; set; }
[DataMember]
public decimal Closing
{
get { return (Opening + Salary) - Paid; }
}
[DataMember]
public byte[] timestamp { get; set; }
}
}
@@ -1,14 +0,0 @@
using System;
using System.Runtime.Serialization;
namespace Tanshu.Accounts.Contracts
{
[DataContract]
public class PaymentSheetDisplayBO : PaymentSheetBO
{
[DataMember]
public string Name { get; set; }
[DataMember]
public string Department { get; set; }
}
}
@@ -3,40 +3,19 @@ using System.Runtime.Serialization;
namespace Tanshu.Accounts.Contracts
{
[DataContract]
public class ProductBO
{
[DataMember]
public Guid ProductID { get; set; }
[DataMember]
public int Code { get; set; }
[DataMember]
public string Name { get; set; }
[DataMember]
public string Units { get; set; }
[DataMember]
public Guid ProductTypeID { get; set; }
[DataMember]
public Guid SaleLedgerID { get; set; }
[DataMember]
public Guid SaleTaxID { get; set; }
[DataMember]
public Guid ProductGroupID { get; set; }
public Guid VatID { get; set; }
public decimal SalePrice { get; set; }
[DataMember]
public Guid PurchaseLedgerID { get; set; }
[DataMember]
public Guid PurchaseTaxID { get; set; }
[DataMember]
public decimal PurchasePrice { get; set; }
[DataMember]
public Guid ServiceTaxID { get; set; }
public bool Discontinued { get; set; }
[DataMember]
public decimal MinimumLevel { get; set; }
[DataMember]
public decimal MaximumLevel { get; set; }
[DataMember]
public byte[] timestamp { get; set; }
[DataMember]
public int SortOrder { get; set; }
}
}
@@ -3,12 +3,9 @@ using System.Runtime.Serialization;
namespace Tanshu.Accounts.Contracts
{
[DataContract]
public class ProductDisplayBO : ProductBO
{
[DataMember]
public decimal Price { get; set; }
[DataMember]
public string Type { get; set; }
}
}
@@ -3,18 +3,12 @@ using System.Runtime.Serialization;
namespace Tanshu.Accounts.Contracts
{
[DataContract]
public class ProductDisplaySmallBO
{
[DataMember]
public int Code { get; set; }
[DataMember]
public string Name { get; set; }
[DataMember]
public decimal Price { get; set; }
[DataMember]
public string Category { get; set; }
[DataMember]
public Guid ProductID { get; set; }
}
}
@@ -3,20 +3,12 @@ using System.Runtime.Serialization;
namespace Tanshu.Accounts.Contracts
{
[DataContract]
public class ProductTypeBO
public class ProductGroupBO
{
[DataMember]
public Guid ProductTypeID { get; set; }
[DataMember]
public Guid ProductGroupID { get; set; }
public string Name { get; set; }
[DataMember]
public decimal DiscountLimit { get; set; }
[DataMember]
public bool IsForSale { get; set; }
[DataMember]
public bool IsForPurchae { get; set; }
[DataMember]
public byte[] timestamp { get; set; }
}
}
@@ -1,45 +0,0 @@
using System;
using System.Runtime.Serialization;
namespace Tanshu.Accounts.Contracts
{
[DataContract]
public class RequirementBO
{
[DataMember]
public Guid RequirementID { get; set; }
[DataMember]
public Guid LedgerID { get; set; }
[DataMember]
public DateTime Date { get; set; }
[DataMember]
public Guid ProductID { get; set; }
[DataMember]
public decimal Requirement { get; set; }
[DataMember]
public string Remarks { get; set; }
[DataMember]
public byte Status { get; set; }
// Status 0 - Pending, 1 - Ordered, 2 - Cancelled, 3 - Fulfilled
[DataMember]
public DateTime StatusDate { get; set; }
[DataMember]
public decimal Stock { get; set; }
[DataMember]
public decimal Price { get; set; }
[DataMember]
public decimal Ordered { get; set; }
[DataMember]
public decimal OrderRate { get; set; }
[DataMember]
public decimal OrderAmount
{
get
{
return Ordered * OrderRate;
}
}
[DataMember]
public byte[] timestamp { get; set; }
}
}
@@ -1,33 +0,0 @@
using System;
using System.Runtime.Serialization;
namespace Tanshu.Accounts.Contracts
{
[DataContract]
public class RequirementDisplayBO : RequirementBO
{
[DataMember]
public string Product { get; set; }
[DataMember]
public string Ledger { get; set; }
[DataMember]
public string StatusDisplay
{
get
{
if (base.Status == 0)
return "Pending";
else if (base.Status == 1)
return "Ordered";
else if (base.Status == 2)
return "Cancelled";
else if (base.Status == 3)
return "Fulfilled";
else
throw new ArgumentException("Status message is invalid");
}
}
[DataMember]
public decimal OrderTotal { get; set; }
}
}
@@ -1,52 +0,0 @@
using System;
using System.Runtime.Serialization;
namespace Tanshu.Accounts.Contracts
{
[DataContract]
public class SalarySheetBO
{
[DataMember]
public Guid SalarySheetID { get; set; }
[DataMember]
public Guid VoucherID { get; set; }
[DataMember]
public Guid LedgerID { get; set; }
[DataMember]
public int Salary { get; set; }
[DataMember]
public decimal WorkingDays { get; set; }
[DataMember]
public decimal Present { get; set; }
[DataMember]
public decimal Offs { get; set; }
[DataMember]
public decimal Overtime { get; set; }
[DataMember]
public int Deductions { get; set; }
[DataMember]
public int TotalSalary
{
get
{
decimal amount = 0;
// Salary
amount = (Present + Offs + Overtime) * Salary / WorkingDays;
// Less Deductions
amount -= Deductions;
// Roundoff
amount = Math.Round(amount);
return Convert.ToInt32(amount);
}
}
[DataMember]
public string Remarks { get; set; }
[DataMember]
public byte[] timestamp { get; set; }
}
}
@@ -1,20 +0,0 @@
using System;
using System.Runtime.Serialization;
namespace Tanshu.Accounts.Contracts
{
[DataContract]
public class SalarySheetDisplayBO : SalarySheetBO
{
[DataMember]
public int Code { get; set; }
[DataMember]
public string Name { get; set; }
[DataMember]
public string CostCenter { get; set; }
[DataMember]
public int CurrentSalary { get; set; }
[DataMember]
public bool IsComputed { get; set; }
}
}
@@ -16,6 +16,5 @@ namespace Tanshu.Accounts.Contracts
public bool Printed { get; set; }
public DateTime? Alarm { get; set; }
public string KotID { get; set; }
public byte[] SaleTimestamp { get; set; }
}
}
@@ -1,42 +1,27 @@
using System;
using System.Runtime.Serialization;
namespace Tanshu.Accounts.Contracts
{
[DataContract]
public class SalesAnalysisBO
{
[DataMember]
public Guid TypeID { get; set; }
[DataMember]
public string Section { get; set; }
[DataMember]
public decimal Quantity { get; set; }
[DataMember]
public decimal Gross { get; set; }
[DataMember]
public Guid ProductGroupID { get; set; }
public string Name { get; set; }
public decimal Net { get; set; }
public decimal Vat { get; set; }
public decimal ServiceTax { get; set; }
}
[DataContract]
public class SalesAnalysisDetailBO
{
[DataMember]
public string Section { get; set; }
[DataMember]
public string Product { get; set; }
[DataMember]
public decimal Quantity { get; set; }
[DataMember]
public decimal Amount { get; set; }
}
[DataContract]
public class SettlementReportBO
{
[DataMember]
public PaidStatus Status { get; set; }
[DataMember]
public decimal Amount { get; set; }
}
}
@@ -3,16 +3,16 @@ using System.Runtime.Serialization;
namespace Tanshu.Accounts.Contracts
{
[DataContract]
public class SalesBillItemBO
{
[DataMember]
public Guid productID;
[DataMember]
public string Name { get; set; }
private decimal price;
[DataMember]
public decimal Price
{
get { return price; }
@@ -26,7 +26,7 @@ namespace Tanshu.Accounts.Contracts
}
private decimal quantity = 1;
[DataMember]
public decimal Quantity
{
get { return quantity; }
@@ -40,7 +40,7 @@ namespace Tanshu.Accounts.Contracts
}
private decimal discount = 0;
[DataMember]
public decimal Discount
{
get { return discount; }
@@ -55,14 +55,31 @@ namespace Tanshu.Accounts.Contracts
}
}
[DataMember]
public decimal Tax { get; set; }
public decimal TaxAmount
public decimal Vat { get; set; }
public decimal VatAmount
{
get
{
return quantity * price * Tax * (1 - discount);
return quantity * price * Vat * (1 - discount);
}
}
public decimal ServiceTax { get; set; }
public decimal ServiceTaxAmount
{
get
{
return quantity * price * ServiceTax * (1 - discount);
}
}
public decimal TotalTax
{
get
{
return quantity * price * (Vat + ServiceTax) * (1 - discount);
}
}
@@ -83,7 +100,7 @@ namespace Tanshu.Accounts.Contracts
}
private decimal printed = 0;
[DataMember]
public decimal Printed
{
get { return printed; }
@@ -95,14 +112,14 @@ namespace Tanshu.Accounts.Contracts
printed = value;
}
}
[DataMember]
public string location;
public decimal Value
{
get
{
return price * quantity * (1 - discount) * (1 + Tax);
return price * quantity * (1 - discount) * (1 + Vat + ServiceTax );
}
}
public decimal Additional
@@ -113,7 +130,7 @@ namespace Tanshu.Accounts.Contracts
}
}
[DataMember]
public bool isNew = true;
public string Display
@@ -122,7 +139,7 @@ namespace Tanshu.Accounts.Contracts
{
string output = string.Format("{0} @ Rs. {1:#.##}", Name, price);
if (discount != 0)
output += string.Format(" - {0:#.##%}", discount);
output += string.Format(" - {0:#.##%}", discount);
return output;
}
}
@@ -3,18 +3,11 @@ using System.Runtime.Serialization;
namespace Tanshu.Accounts.Contracts
{
[DataContract]
public class TaxBO
{
[DataMember]
public Guid TaxID { get; set; }
[DataMember]
public string Name { get; set; }
[DataMember]
public decimal Rate { get; set; }
[DataMember]
public char Type { get; set; }
[DataMember]
private byte[] timestamp { get; set; }
}
}
@@ -3,18 +3,11 @@ using System.Runtime.Serialization;
namespace Tanshu.Accounts.Contracts
{
[DataContract]
public class UserBO
{
[DataMember]
public Guid UserID { get; set; }
[DataMember]
public string Name { get; set; }
[DataMember]
public string Password { get; set; }
[DataMember]
public bool LockedOut { get; set; }
[DataMember]
public byte[] timestamp { get; set; }
}
}
@@ -3,25 +3,16 @@ using System.Runtime.Serialization;
namespace Tanshu.Accounts.Contracts
{
[DataContract]
public class VerificationBO
{
[DataMember]
public Guid VerificationID { get; set; }
[DataMember]
public Guid VoucherID { get; set; }
[DataMember]
public Guid ProductID { get; set; }
[DataMember]
public decimal ActualQuantity { get; set; }
[DataMember]
public decimal ComputedQuantity { get; set; }
[DataMember]
public decimal LostQuantity
{
get { return ComputedQuantity - ActualQuantity; }
}
[DataMember]
public byte[] Timestamp { get; set; }
}
}
@@ -3,10 +3,8 @@ using System.Runtime.Serialization;
namespace Tanshu.Accounts.Contracts
{
[DataContract]
public class VerificationDisplayBO : VerificationBO
{
[DataMember]
public string ProductName { get; set; }
}
}
@@ -3,28 +3,22 @@ using System.Runtime.Serialization;
namespace Tanshu.Accounts.Contracts
{
[DataContract]
public class VoucherBO
{
[DataMember]
public Guid VoucherID { get; set; }
[DataMember]
public int Code { get; set; }
[DataMember]
public string Ref { get; set; }
[DataMember]
public DateTime? Date { get; set; }
[DataMember]
public string Narration { get; set; }
[DataMember]
public Guid UserID { get; set; }
[DataMember]
public DateTime CreationDate { get; set; }
[DataMember]
public DateTime LastEditDate { get; set; }
[DataMember]
public char Type { get; set; }
[DataMember]
public byte[] timestamp { get; set; }
}
}
@@ -3,16 +3,10 @@ using System.Runtime.Serialization;
namespace Tanshu.Accounts.Contracts
{
[DataContract]
public class WaiterBO
{
[DataMember]
public Guid WaiterID { get; set; }
[DataMember]
public int Code { get; set; }
[DataMember]
public string Name { get; set; }
[DataMember]
public byte[] timestamp { get; set; }
}
}
@@ -1,19 +0,0 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.ServiceModel;
using System.Data.SqlClient;
namespace Tanshu.Accounts.Contracts
{
[ServiceContract]
public interface IAdvanceBI
{
[OperationContract]
void Insert(AdvanceBO advance);
[OperationContract]
List<AdvanceDisplayBO> GetAdvances(DateTime fromDate, DateTime toDate, bool all);
[OperationContract]
void Adjust(Guid advanceID, Guid userID);
}
}
@@ -1,75 +0,0 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading;
using System.Data.SqlClient;
using System.ServiceModel;
using System.Runtime.Serialization;
namespace Tanshu.Accounts.Contracts
{
[ServiceContract]
public interface ICheckoutBI
{
#region Properties
[DataMember]
decimal Opening { get; }
[DataMember]
decimal Receipts { get; }
[DataMember]
decimal AdvanceReceipts { get; }
[DataMember]
decimal CCReceipts { get; }
[DataMember]
decimal AdvanceAdjusted { get; }
[DataMember]
decimal CashPayments { get; }
[DataMember]
decimal AdditionalVoids { get; }
[DataMember]
decimal VoidsInSystem { get; }
[DataMember]
decimal PendingBills { get; }
[DataMember]
decimal NetSales { get; }
[DataMember]
decimal ClosingBalance { get; }
[DataMember]
decimal RetainedOvernight { get; }
[DataMember]
decimal CashDeposited { get; } //
[DataMember]
decimal Excess { get; } //
[DataMember]
string Status { get; } //
[DataMember]
string Cashiers { get; } //
[DataMember]
Guid CashierID { get; } //
[DataMember]
string Cashier { get; } //
[DataMember]
DateTime StartDate { get; } //
[DataMember]
DateTime FinishDate { get; } //
[DataMember]
string PendingString { get; }
[DataMember]
string CCString { get; }
[DataMember]
string VoidsString { get; }
[DataMember]
string DiscountString { get; }
[DataMember]
string Manager { get; }
#endregion
[OperationContract]
void Init(Guid cashier, DateTime startDate, DateTime finishDate);
[OperationContract]
void Calculate(decimal cashDeposited, decimal retainedOvernight);
}
}
@@ -1,31 +0,0 @@
using System;
using System.Collections.Generic;
//using System.Linq;
using System.Text;
using System.ServiceModel;
using System.Data.SqlClient;
namespace Tanshu.Accounts.Contracts
{
[ServiceContract]
public interface ICustomerBI
{
[OperationContract]
List<LedgerBO> GetCustomerLedgers();
[OperationContract]
CustomerBO GetCustomer(Guid customerID);
[OperationContract]
List<CustomerBO> GetFilteredCustomers(Dictionary<string, string> filter);
[OperationContract]
List<CustomerBO> GetCustomers();
[OperationContract]
List<CustomerBO> GetSingleCustomers(Guid customerID);
[OperationContract]
bool Update(CustomerBO customer);
[OperationContract]
bool Delete(Guid customerID);
[OperationContract]
bool Insert(CustomerBO customer);
}
}
@@ -1,26 +0,0 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.ServiceModel;
using System.Data.SqlClient;
namespace Tanshu.Accounts.Contracts
{
[ServiceContract]
public interface ILedgerBI
{
[OperationContract]
LedgerBO GetLedger(Guid ledgerID);
[OperationContract]
LedgerBO GetLedgerByName(string name);
[OperationContract]
bool Insert(LedgerBO ledger);
[OperationContract]
bool Update(LedgerBO ledger);
[OperationContract]
List<LedgerDisplayBO> GetLedgers();
[OperationContract]
List<LedgerDisplayBO> GetLedgersOfType(char type);
}
}
@@ -1,28 +0,0 @@
using System;
using System.Collections.Generic;
//using System.Linq;
using System.Text;
using System.Data.SqlClient;
using System.ServiceModel;
namespace Tanshu.Accounts.Contracts
{
[ServiceContract]
public interface IMembershipBI
{
[OperationContract]
bool ValidateUser(string name, string password);
[OperationContract]
void AddUsersToRoles(string[] usernames, string[] roleNames);
[OperationContract]
string[] GetAllRoles();
[OperationContract]
string[] GetRolesForUser(string username);
[OperationContract]
bool IsUserInRole(string username, string roleName);
[OperationContract]
void RemoveUsersFromRoles(string[] usernames, string[] roleNames);
[OperationContract]
UserBO GetUserFromName(string name);
}
}
@@ -1,20 +0,0 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.ServiceModel;
using System.Data.SqlClient;
namespace Tanshu.Accounts.Contracts
{
[ServiceContract]
public interface IPaymentBI
{
[OperationContract]
void Insert(PaymentBO payment);
[OperationContract]
List<PaymentDisplayBO> GetPayments(Guid? userID, DateTime fromDate, DateTime toDate);
[OperationContract]
void Delete(Guid paymentID);
}
}
@@ -1,31 +0,0 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.ServiceModel;
using System.Data.SqlClient;
namespace Tanshu.Accounts.Contracts
{
[ServiceContract]
public interface IProductBI
{
[OperationContract]
bool Insert(ProductBO product);
[OperationContract]
bool Update(ProductBO product);
[OperationContract]
bool Delete(Guid productID);
[OperationContract]
ProductBO GetProductFromName(string nameAndUnits);
[OperationContract]
ProductBO GetProduct(Guid productID);
[OperationContract]
decimal GetProductStock(DateTime date, Guid productID, Guid? voucherID);
[OperationContract]
List<ProductDisplayBO> GetProducts();
[OperationContract]
List<ProductDisplaySmallBO> GetFilteredProducts(Dictionary<string, string> filter);
[OperationContract]
List<ProductTypeBO> GetProductTypes();
}
}
@@ -1,37 +0,0 @@
using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.ServiceModel;
namespace Tanshu.Accounts.Contracts
{
[ServiceContract]
public interface ISaleVoucherBI
{
[OperationContract]
SalesBillItemBO GetDefaultSaleBillItem(Guid productID);
[OperationContract]
decimal GetProductDiscountLimit(Guid productID);
[OperationContract]
bool IsBillPrinted(Guid voucherID);
[OperationContract]
bool Insert(SaleVoucherBO saleVoucher, List<InventoryBO> inventory);
[OperationContract]
bool Update(SaleVoucherBO saleVoucher, List<InventoryBO> inventory);
[OperationContract]
bool GetSaleVoucher(Guid voucherID, ref SaleVoucherBO voucherSale, ref List<InventoryDisplayBO> iList);
[OperationContract]
List<PendingBillsBO> GetPendingBills(PendingType list, int floor);
[OperationContract]
Guid? GetPendingVoucherID(string tableID, int floor);
[OperationContract]
List<InventoryBO> SaleInventory(Dictionary<BillItemKey, SalesBillItemBO>.ValueCollection list, Guid? voucherID);
[OperationContract]
void SetAlarm(Guid voucherID, DateTime? alarmTime);
[OperationContract]
void VoidBill(Guid voucherID, string reason, Guid userID);
[OperationContract]
void DeclareBillsPaid(Guid userID, List<Guid> billList, PaidStatus paidStatus);
}
}
@@ -1,23 +0,0 @@
using System;
using System.Collections.Generic;
//using System.Linq;
using System.Text;
using System.Data.SqlClient;
using System.ServiceModel;
namespace Tanshu.Accounts.Contracts
{
[ServiceContract]
public interface ISalesAnalysisBI
{
[OperationContract]
List<SalesAnalysisDetailBO> GetSaleDetail(DateTime startDate, DateTime finishDate, Guid costCenterID);
[OperationContract]
List<SalesAnalysisBO> GetSale(DateTime startDate, DateTime finishDate);
[OperationContract]
void GetAdditionalInfo(ref decimal freeSale, ref decimal voids, ref decimal pending, ref decimal net, ref decimal tax, DateTime startDate, DateTime finishDate);
[OperationContract]
List<SalesAnalysisBO> GetSalesTaxReturn(DateTime startDate, DateTime finishDate, ref decimal freeSale, ref decimal voids, ref decimal pending, ref decimal net, ref decimal tax);
}
}
@@ -1,27 +0,0 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.ServiceModel;
using System.Data.SqlClient;
namespace Tanshu.Accounts.Contracts
{
[ServiceContract]
public interface IUserBI
{
[OperationContract]
UserBO GetUser(Guid userID);
[OperationContract]
bool ChangePassword(UserBO userData, string newPassword);
[OperationContract]
List<UserBO> GetUsers();
[OperationContract]
bool UserExists(string userName);
[OperationContract]
bool Insert(UserBO user);
[OperationContract]
bool Update(UserBO user);
[OperationContract]
bool Delete(Guid userID);
}
}
@@ -1,23 +0,0 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.ServiceModel;
using System.Data.SqlClient;
namespace Tanshu.Accounts.Contracts
{
[ServiceContract]
public interface IWaiterBI
{
[OperationContract]
bool Insert(WaiterBO waiter);
[OperationContract]
bool Update(WaiterBO waiter);
[OperationContract]
WaiterBO GetWaiter(Guid waiterID);
[OperationContract]
bool Delete(Guid waiterID);
[OperationContract]
List<WaiterBO> GetWaiters();
}
}
@@ -56,52 +56,28 @@
<Compile Include="Communication\Delegates.cs" />
<Compile Include="Data Contracts\AdvanceBO.cs" />
<Compile Include="Data Contracts\AdvanceDisplayBO.cs" />
<Compile Include="Data Contracts\ComplexProductBO.cs" />
<Compile Include="Data Contracts\BillItemKey.cs" />
<Compile Include="Data Contracts\PaidStatusBO.cs" />
<Compile Include="Data Contracts\SalarySheetBO.cs" />
<Compile Include="Data Contracts\SalarySheetDisplayBO.cs" />
<Compile Include="Data Contracts\TaxBO.cs" />
<Compile Include="Data Contracts\VerificationBO.cs" />
<Compile Include="Data Contracts\VerificationDisplayBO.cs" />
<Compile Include="Data Contracts\RequirementDisplayBO.cs" />
<Compile Include="Data Contracts\RequirementBO.cs" />
<Compile Include="Data Contracts\PaymentSheetBO.cs" />
<Compile Include="Data Contracts\PaymentSheetDisplayBO.cs" />
<Compile Include="Data Contracts\LedgerTypeBO.cs" />
<Compile Include="Data Contracts\JournalDisplayBO.cs" />
<Compile Include="Data Contracts\CostCenterBO.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\JournalBO.cs" />
<Compile Include="Data Contracts\LedgerBO.cs" />
<Compile Include="Data Contracts\LedgerDisplayBO.cs" />
<Compile Include="Data Contracts\PaymentBO.cs" />
<Compile Include="Data Contracts\PaymentDisplayBO.cs" />
<Compile Include="Data Contracts\PendingBillsBO.cs" />
<Compile Include="Data Contracts\ProductBO.cs" />
<Compile Include="Data Contracts\ProductDisplayBO.cs" />
<Compile Include="Data Contracts\ProductDisplaySmallBO.cs" />
<Compile Include="Data Contracts\ProductTypeBO.cs" />
<Compile Include="Data Contracts\ProductGroupBO.cs" />
<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" />
<Compile Include="Service Contracts\AdvanceBI.cs" />
<Compile Include="Service Contracts\CheckoutBI.cs" />
<Compile Include="Service Contracts\CustomerBI.cs" />
<Compile Include="Service Contracts\WaiterBI.cs" />
<Compile Include="Service Contracts\LedgerBI.cs" />
<Compile Include="Service Contracts\MembershipBI.cs" />
<Compile Include="Service Contracts\PaymentBI.cs" />
<Compile Include="Service Contracts\ProductBI.cs" />
<Compile Include="Service Contracts\SalesAnalysisBI.cs" />
<Compile Include="Service Contracts\SaleVoucherBI.cs" />
<Compile Include="Service Contracts\UserBI.cs" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
-1
View File
@@ -17,7 +17,6 @@ namespace Tanshu.Accounts.Helpers
: base(getData, true, "List of Bills")
{
//grid.Columns["CustomerID"].Visible = false;
//grid.Columns["LedgerID"].Visible = false;
}
protected override void FilterChanged(Dictionary<string, string> filter)
@@ -21,7 +21,6 @@ namespace Tanshu.Accounts.Helpers
filters.Add("Universal");
SetFilterColumns(filters);
grid.Columns["CustomerID"].Visible = false;
grid.Columns["LedgerID"].Visible = false;
}
protected override void FilterChanged(Dictionary<string, string> filter)
-1
View File
@@ -20,7 +20,6 @@ namespace Tanshu.Accounts.Helpers
filters.Add("Name");
SetFilterColumns(filters);
grid.Columns["UserID"].Visible = false;
grid.Columns["timestamp"].Visible = false;
}
protected override void FilterChanged(Dictionary<string, string> filter)
-1
View File
@@ -20,7 +20,6 @@ namespace Tanshu.Accounts.Helpers
filters.Add("Name");
SetFilterColumns(filters);
grid.Columns["WaiterID"].Visible = false;
grid.Columns["timestamp"].Visible = false;
}
protected override void FilterChanged(Dictionary<string, string> filter)
+3 -17
View File
@@ -216,9 +216,9 @@ namespace Tanshu.Accounts.PointOfSale
private void prToolStripMenuItem_Click(object sender, EventArgs e)
{
ProductTypes ProductType = new ProductTypes();
ProductType.ShowDialog();
ProductType.Dispose();
ProductGroups ProductGroup = new ProductGroups();
ProductGroup.ShowDialog();
ProductGroup.Dispose();
}
private void toolStripMenuItem1_Click(object sender, EventArgs e)
@@ -240,20 +240,6 @@ namespace Tanshu.Accounts.PointOfSale
}
private void complexProductsToolStripMenuItem_Click(object sender, EventArgs e)
{
if (!Thread.CurrentPrincipal.IsInRole("Master/Products"))
{
MessageBox.Show("You are not authorized to access");
}
else
{
//ComplexProductForm form = new ComplexProductForm();
//form.ShowDialog();
//form.Dispose();
}
}
private void viewLogToolStripMenuItem_Click(object sender, EventArgs e)
{
if (!Thread.CurrentPrincipal.IsInRole("Log/View"))
+8 -18
View File
@@ -55,7 +55,6 @@
this.masterToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.prToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.productsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.complexProductsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.customersToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.updateToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.reportToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
@@ -316,7 +315,6 @@
this.masterToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.prToolStripMenuItem,
this.productsToolStripMenuItem,
this.complexProductsToolStripMenuItem,
this.customersToolStripMenuItem,
this.updateToolStripMenuItem,
this.reportToolStripMenuItem,
@@ -330,56 +328,49 @@
// prToolStripMenuItem
//
this.prToolStripMenuItem.Name = "prToolStripMenuItem";
this.prToolStripMenuItem.Size = new System.Drawing.Size(171, 22);
this.prToolStripMenuItem.Text = "Product Type";
this.prToolStripMenuItem.Size = new System.Drawing.Size(157, 22);
this.prToolStripMenuItem.Text = "Product Groups";
this.prToolStripMenuItem.Click += new System.EventHandler(this.prToolStripMenuItem_Click);
//
// productsToolStripMenuItem
//
this.productsToolStripMenuItem.Name = "productsToolStripMenuItem";
this.productsToolStripMenuItem.Size = new System.Drawing.Size(171, 22);
this.productsToolStripMenuItem.Size = new System.Drawing.Size(157, 22);
this.productsToolStripMenuItem.Text = "Products";
this.productsToolStripMenuItem.Click += new System.EventHandler(this.productsToolStripMenuItem_Click);
//
// complexProductsToolStripMenuItem
//
this.complexProductsToolStripMenuItem.Name = "complexProductsToolStripMenuItem";
this.complexProductsToolStripMenuItem.Size = new System.Drawing.Size(171, 22);
this.complexProductsToolStripMenuItem.Text = "Complex Products";
this.complexProductsToolStripMenuItem.Click += new System.EventHandler(this.complexProductsToolStripMenuItem_Click);
//
// customersToolStripMenuItem
//
this.customersToolStripMenuItem.Name = "customersToolStripMenuItem";
this.customersToolStripMenuItem.Size = new System.Drawing.Size(171, 22);
this.customersToolStripMenuItem.Size = new System.Drawing.Size(157, 22);
this.customersToolStripMenuItem.Text = "Customers";
this.customersToolStripMenuItem.Click += new System.EventHandler(this.customersToolStripMenuItem_Click);
//
// updateToolStripMenuItem
//
this.updateToolStripMenuItem.Name = "updateToolStripMenuItem";
this.updateToolStripMenuItem.Size = new System.Drawing.Size(171, 22);
this.updateToolStripMenuItem.Size = new System.Drawing.Size(157, 22);
this.updateToolStripMenuItem.Text = "Update";
this.updateToolStripMenuItem.Click += new System.EventHandler(this.updateToolStripMenuItem_Click);
//
// reportToolStripMenuItem
//
this.reportToolStripMenuItem.Name = "reportToolStripMenuItem";
this.reportToolStripMenuItem.Size = new System.Drawing.Size(171, 22);
this.reportToolStripMenuItem.Size = new System.Drawing.Size(157, 22);
this.reportToolStripMenuItem.Text = "Report";
this.reportToolStripMenuItem.Click += new System.EventHandler(this.reportToolStripMenuItem_Click);
//
// autoToolStripMenuItem
//
this.autoToolStripMenuItem.Name = "autoToolStripMenuItem";
this.autoToolStripMenuItem.Size = new System.Drawing.Size(171, 22);
this.autoToolStripMenuItem.Size = new System.Drawing.Size(157, 22);
this.autoToolStripMenuItem.Text = "Auto";
this.autoToolStripMenuItem.Click += new System.EventHandler(this.autoToolStripMenuItem_Click);
//
// updateBillsToolStripMenuItem
//
this.updateBillsToolStripMenuItem.Name = "updateBillsToolStripMenuItem";
this.updateBillsToolStripMenuItem.Size = new System.Drawing.Size(171, 22);
this.updateBillsToolStripMenuItem.Size = new System.Drawing.Size(157, 22);
this.updateBillsToolStripMenuItem.Text = "Update Bills";
this.updateBillsToolStripMenuItem.Click += new System.EventHandler(this.updateBillsToolStripMenuItem_Click);
//
@@ -556,7 +547,6 @@
private System.Windows.Forms.ToolStripMenuItem salesAnalysisToolStripMenuItem1;
private System.Windows.Forms.ToolStripMenuItem cashierCheckoutToolStripMenuItem1;
private System.Windows.Forms.ToolStripMenuItem prToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem complexProductsToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem updateToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem reportToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem autoToolStripMenuItem;
@@ -1,6 +1,6 @@
namespace Tanshu.Accounts.PointOfSale
{
partial class ProductTypes
partial class ProductGroups
{
/// <summary>
/// Required designer variable.
@@ -200,7 +200,7 @@
this.Label5.TabIndex = 73;
this.Label5.Text = "Discount Limit";
//
// ProductTypes
// ProductGroups
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
@@ -224,7 +224,7 @@
this.Controls.Add(this.Label1);
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "ProductTypes";
this.Name = "ProductGroups";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "Product Types";
this.ResumeLayout(false);
@@ -9,9 +9,9 @@ using System.Windows.Forms;
namespace Tanshu.Accounts.PointOfSale
{
public partial class ProductTypes : Form
public partial class ProductGroups : Form
{
public ProductTypes()
public ProductGroups()
{
InitializeComponent();
}
+64 -159
View File
@@ -34,7 +34,7 @@
this.bsProducts = new System.Windows.Forms.BindingSource(this.components);
this.GroupBox1 = new System.Windows.Forms.GroupBox();
this.btnAddCategory = new System.Windows.Forms.Button();
this.cmbProductTypes = new System.Windows.Forms.ComboBox();
this.cmbProductGroups = new System.Windows.Forms.ComboBox();
this.bsTypes = new System.Windows.Forms.BindingSource(this.components);
this.cmbUnits = new System.Windows.Forms.ComboBox();
this.bsUnits = new System.Windows.Forms.BindingSource(this.components);
@@ -58,28 +58,18 @@
this.txtMaximumLevel = new System.Windows.Forms.TextBox();
this.label9 = new System.Windows.Forms.Label();
this.chkDiscontinued = new System.Windows.Forms.CheckBox();
this.cmbSalesLedger = new System.Windows.Forms.ComboBox();
this.bsSalesLedgers = new System.Windows.Forms.BindingSource(this.components);
this.label5 = new System.Windows.Forms.Label();
this.cmbSalesTax = new System.Windows.Forms.ComboBox();
this.bsSalesTax = new System.Windows.Forms.BindingSource(this.components);
this.cmbVat = new System.Windows.Forms.ComboBox();
this.bsVat = new System.Windows.Forms.BindingSource(this.components);
this.label10 = new System.Windows.Forms.Label();
this.cmbPurchaseTax = new System.Windows.Forms.ComboBox();
this.bsPurchaseTax = new System.Windows.Forms.BindingSource(this.components);
this.label11 = new System.Windows.Forms.Label();
this.cmbPurchaseLedger = new System.Windows.Forms.ComboBox();
this.bsPurchaseLedgers = new System.Windows.Forms.BindingSource(this.components);
this.label12 = new System.Windows.Forms.Label();
this.label13 = new System.Windows.Forms.Label();
this.txtPurchasePrice = new System.Windows.Forms.TextBox();
this.cmbServiceTax = new System.Windows.Forms.ComboBox();
this.bsServiceTax = new System.Windows.Forms.BindingSource(this.components);
this.label8 = new System.Windows.Forms.Label();
((System.ComponentModel.ISupportInitialize)(this.bsProducts)).BeginInit();
this.GroupBox1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.bsTypes)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.bsUnits)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.bsSalesLedgers)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.bsSalesTax)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.bsPurchaseTax)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.bsPurchaseLedgers)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.bsVat)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.bsServiceTax)).BeginInit();
this.SuspendLayout();
//
// Label4
@@ -110,7 +100,7 @@
// GroupBox1
//
this.GroupBox1.Controls.Add(this.btnAddCategory);
this.GroupBox1.Controls.Add(this.cmbProductTypes);
this.GroupBox1.Controls.Add(this.cmbProductGroups);
this.GroupBox1.Controls.Add(this.cmbUnits);
this.GroupBox1.Controls.Add(this.Label7);
this.GroupBox1.Controls.Add(this.Label3);
@@ -131,21 +121,21 @@
this.btnAddCategory.Text = "+";
this.btnAddCategory.Click += new System.EventHandler(this.btnAddCategory_Click);
//
// cmbProductTypes
// cmbProductGroups
//
this.cmbProductTypes.DataBindings.Add(new System.Windows.Forms.Binding("SelectedValue", this.bsProducts, "ProductTypeID", true));
this.cmbProductTypes.DataSource = this.bsTypes;
this.cmbProductTypes.DisplayMember = "Name";
this.cmbProductTypes.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.cmbProductTypes.Location = new System.Drawing.Point(94, 72);
this.cmbProductTypes.Name = "cmbProductTypes";
this.cmbProductTypes.Size = new System.Drawing.Size(181, 21);
this.cmbProductTypes.TabIndex = 35;
this.cmbProductTypes.ValueMember = "ProductTypeID";
this.cmbProductGroups.DataBindings.Add(new System.Windows.Forms.Binding("SelectedValue", this.bsProducts, "ProductGroupID", true));
this.cmbProductGroups.DataSource = this.bsTypes;
this.cmbProductGroups.DisplayMember = "Name";
this.cmbProductGroups.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.cmbProductGroups.Location = new System.Drawing.Point(94, 72);
this.cmbProductGroups.Name = "cmbProductGroups";
this.cmbProductGroups.Size = new System.Drawing.Size(181, 21);
this.cmbProductGroups.TabIndex = 35;
this.cmbProductGroups.ValueMember = "ProductGroupID";
//
// bsTypes
//
this.bsTypes.DataSource = typeof(Tanshu.Accounts.Contracts.ProductTypeBO);
this.bsTypes.DataSource = typeof(Tanshu.Accounts.Contracts.ProductGroupBO);
//
// cmbUnits
//
@@ -356,141 +346,66 @@
this.chkDiscontinued.Text = "Discontinued";
this.chkDiscontinued.UseVisualStyleBackColor = true;
//
// cmbSalesLedger
// cmbVat
//
this.cmbSalesLedger.DataBindings.Add(new System.Windows.Forms.Binding("SelectedValue", this.bsProducts, "SaleLedgerID", true));
this.cmbSalesLedger.DataSource = this.bsSalesLedgers;
this.cmbSalesLedger.DisplayMember = "Name";
this.cmbSalesLedger.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.cmbSalesLedger.Location = new System.Drawing.Point(93, 163);
this.cmbSalesLedger.Name = "cmbSalesLedger";
this.cmbSalesLedger.Size = new System.Drawing.Size(137, 21);
this.cmbSalesLedger.TabIndex = 80;
this.cmbSalesLedger.ValueMember = "LedgerID";
this.cmbVat.DataBindings.Add(new System.Windows.Forms.Binding("SelectedValue", this.bsProducts, "VatID", true));
this.cmbVat.DataSource = this.bsVat;
this.cmbVat.DisplayMember = "Name";
this.cmbVat.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.cmbVat.Location = new System.Drawing.Point(236, 163);
this.cmbVat.Name = "cmbVat";
this.cmbVat.Size = new System.Drawing.Size(91, 21);
this.cmbVat.TabIndex = 82;
this.cmbVat.ValueMember = "TaxID";
//
// bsSalesLedgers
// bsVat
//
this.bsSalesLedgers.DataSource = typeof(Tanshu.Accounts.Contracts.LedgerBO);
//
// label5
//
this.label5.AutoSize = true;
this.label5.Location = new System.Drawing.Point(98, 148);
this.label5.Name = "label5";
this.label5.Size = new System.Drawing.Size(69, 13);
this.label5.TabIndex = 79;
this.label5.Text = "Sales Ledger";
//
// cmbSalesTax
//
this.cmbSalesTax.DataBindings.Add(new System.Windows.Forms.Binding("SelectedValue", this.bsProducts, "SaleTaxID", true));
this.cmbSalesTax.DataSource = this.bsSalesTax;
this.cmbSalesTax.DisplayMember = "Name";
this.cmbSalesTax.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.cmbSalesTax.Location = new System.Drawing.Point(236, 163);
this.cmbSalesTax.Name = "cmbSalesTax";
this.cmbSalesTax.Size = new System.Drawing.Size(91, 21);
this.cmbSalesTax.TabIndex = 82;
this.cmbSalesTax.ValueMember = "LedgerID";
//
// bsSalesTax
//
this.bsSalesTax.DataSource = typeof(Tanshu.Accounts.Contracts.LedgerBO);
this.bsVat.DataSource = typeof(Tanshu.Accounts.Contracts.TaxBO);
//
// label10
//
this.label10.AutoSize = true;
this.label10.Location = new System.Drawing.Point(241, 148);
this.label10.Name = "label10";
this.label10.Size = new System.Drawing.Size(54, 13);
this.label10.Size = new System.Drawing.Size(23, 13);
this.label10.TabIndex = 81;
this.label10.Text = "Sales Tax";
this.label10.Text = "Vat";
//
// cmbPurchaseTax
// cmbServiceTax
//
this.cmbPurchaseTax.DataBindings.Add(new System.Windows.Forms.Binding("SelectedValue", this.bsProducts, "PurchaseTaxID", true));
this.cmbPurchaseTax.DataSource = this.bsPurchaseTax;
this.cmbPurchaseTax.DisplayMember = "Name";
this.cmbPurchaseTax.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.cmbPurchaseTax.Location = new System.Drawing.Point(233, 214);
this.cmbPurchaseTax.Name = "cmbPurchaseTax";
this.cmbPurchaseTax.Size = new System.Drawing.Size(91, 21);
this.cmbPurchaseTax.TabIndex = 88;
this.cmbPurchaseTax.ValueMember = "LedgerID";
this.cmbServiceTax.DataBindings.Add(new System.Windows.Forms.Binding("SelectedValue", this.bsProducts, "VatID", true));
this.cmbServiceTax.DataSource = this.bsServiceTax;
this.cmbServiceTax.DisplayMember = "Name";
this.cmbServiceTax.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.cmbServiceTax.Location = new System.Drawing.Point(236, 205);
this.cmbServiceTax.Name = "cmbServiceTax";
this.cmbServiceTax.Size = new System.Drawing.Size(91, 21);
this.cmbServiceTax.TabIndex = 84;
this.cmbServiceTax.ValueMember = "TaxID";
//
// bsPurchaseTax
// bsServiceTax
//
this.bsPurchaseTax.DataSource = typeof(Tanshu.Accounts.Contracts.LedgerBO);
this.bsServiceTax.DataSource = typeof(Tanshu.Accounts.Contracts.TaxBO);
//
// label11
// label8
//
this.label11.AutoSize = true;
this.label11.Location = new System.Drawing.Point(233, 198);
this.label11.Name = "label11";
this.label11.Size = new System.Drawing.Size(73, 13);
this.label11.TabIndex = 87;
this.label11.Text = "Purchase Tax";
//
// cmbPurchaseLedger
//
this.cmbPurchaseLedger.DataBindings.Add(new System.Windows.Forms.Binding("SelectedValue", this.bsProducts, "PurchaseLedgerID", true));
this.cmbPurchaseLedger.DataSource = this.bsPurchaseLedgers;
this.cmbPurchaseLedger.DisplayMember = "Name";
this.cmbPurchaseLedger.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.cmbPurchaseLedger.Location = new System.Drawing.Point(90, 214);
this.cmbPurchaseLedger.Name = "cmbPurchaseLedger";
this.cmbPurchaseLedger.Size = new System.Drawing.Size(137, 21);
this.cmbPurchaseLedger.TabIndex = 86;
this.cmbPurchaseLedger.ValueMember = "LedgerID";
//
// bsPurchaseLedgers
//
this.bsPurchaseLedgers.DataSource = typeof(Tanshu.Accounts.Contracts.LedgerBO);
//
// label12
//
this.label12.AutoSize = true;
this.label12.Location = new System.Drawing.Point(95, 198);
this.label12.Name = "label12";
this.label12.Size = new System.Drawing.Size(88, 13);
this.label12.TabIndex = 85;
this.label12.Text = "Purchase Ledger";
//
// label13
//
this.label13.AutoSize = true;
this.label13.Location = new System.Drawing.Point(10, 198);
this.label13.Name = "label13";
this.label13.Size = new System.Drawing.Size(79, 13);
this.label13.TabIndex = 84;
this.label13.Text = "Purchase Price";
//
// txtPurchasePrice
//
this.txtPurchasePrice.AccessibleName = "Phone 1";
this.txtPurchasePrice.DataBindings.Add(new System.Windows.Forms.Binding("Text", this.bsProducts, "PurchasePrice", true));
this.txtPurchasePrice.Location = new System.Drawing.Point(10, 214);
this.txtPurchasePrice.Name = "txtPurchasePrice";
this.txtPurchasePrice.Size = new System.Drawing.Size(74, 20);
this.txtPurchasePrice.TabIndex = 83;
this.txtPurchasePrice.Text = "0";
this.label8.AutoSize = true;
this.label8.Location = new System.Drawing.Point(241, 190);
this.label8.Name = "label8";
this.label8.Size = new System.Drawing.Size(64, 13);
this.label8.TabIndex = 83;
this.label8.Text = "Service Tax";
//
// ProductsForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(336, 365);
this.Controls.Add(this.cmbPurchaseTax);
this.Controls.Add(this.label11);
this.Controls.Add(this.cmbPurchaseLedger);
this.Controls.Add(this.label12);
this.Controls.Add(this.label13);
this.Controls.Add(this.txtPurchasePrice);
this.Controls.Add(this.cmbSalesTax);
this.Controls.Add(this.cmbServiceTax);
this.Controls.Add(this.label8);
this.Controls.Add(this.cmbVat);
this.Controls.Add(this.Label1);
this.Controls.Add(this.label10);
this.Controls.Add(this.cmbSalesLedger);
this.Controls.Add(this.label5);
this.Controls.Add(this.chkDiscontinued);
this.Controls.Add(this.txtMaximumLevel);
this.Controls.Add(this.label9);
@@ -520,10 +435,8 @@
this.GroupBox1.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.bsTypes)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.bsUnits)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.bsSalesLedgers)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.bsSalesTax)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.bsPurchaseTax)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.bsPurchaseLedgers)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.bsVat)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.bsServiceTax)).EndInit();
this.ResumeLayout(false);
this.PerformLayout();
@@ -535,7 +448,7 @@
internal System.Windows.Forms.TextBox txtSalePrice;
internal System.Windows.Forms.GroupBox GroupBox1;
internal System.Windows.Forms.Button btnAddCategory;
internal System.Windows.Forms.ComboBox cmbProductTypes;
internal System.Windows.Forms.ComboBox cmbProductGroups;
internal System.Windows.Forms.ComboBox cmbUnits;
internal System.Windows.Forms.Label Label7;
internal System.Windows.Forms.Label Label3;
@@ -557,22 +470,14 @@
internal System.Windows.Forms.TextBox txtMaximumLevel;
internal System.Windows.Forms.Label label9;
private System.Windows.Forms.CheckBox chkDiscontinued;
internal System.Windows.Forms.ComboBox cmbSalesLedger;
internal System.Windows.Forms.Label label5;
internal System.Windows.Forms.ComboBox cmbSalesTax;
internal System.Windows.Forms.ComboBox cmbVat;
internal System.Windows.Forms.Label label10;
internal System.Windows.Forms.ComboBox cmbPurchaseTax;
internal System.Windows.Forms.Label label11;
internal System.Windows.Forms.ComboBox cmbPurchaseLedger;
internal System.Windows.Forms.Label label12;
internal System.Windows.Forms.Label label13;
internal System.Windows.Forms.TextBox txtPurchasePrice;
private System.Windows.Forms.BindingSource bsProducts;
private System.Windows.Forms.BindingSource bsUnits;
private System.Windows.Forms.BindingSource bsTypes;
private System.Windows.Forms.BindingSource bsSalesLedgers;
private System.Windows.Forms.BindingSource bsSalesTax;
private System.Windows.Forms.BindingSource bsPurchaseLedgers;
private System.Windows.Forms.BindingSource bsPurchaseTax;
private System.Windows.Forms.BindingSource bsVat;
private System.Windows.Forms.BindingSource bsServiceTax;
internal System.Windows.Forms.ComboBox cmbServiceTax;
internal System.Windows.Forms.Label label8;
}
}
+11 -19
View File
@@ -48,11 +48,9 @@ namespace Tanshu.Accounts.PointOfSale
new StringType ("Bottle"),
new StringType ("Pack" )};
bsTypes.DataSource = new ProductBI().GetProductTypes();
bsPurchaseLedgers.DataSource = new LedgerBI().GetLedgersOfType('P');
bsSalesLedgers.DataSource = new LedgerBI().GetLedgersOfType('X');
bsSalesTax.DataSource = new LedgerBI().GetLedgersOfType('T');
bsPurchaseTax.DataSource = new LedgerBI().GetLedgersOfType('T');
bsTypes.DataSource = new ProductBI().GetProductGroups();
bsVat.DataSource = new ProductBI().GetTaxes();
bsServiceTax.DataSource = new ProductBI().GetTaxes();
}
#endregion
@@ -129,10 +127,8 @@ namespace Tanshu.Accounts.PointOfSale
{
bool returnType;
returnType = (bool)(txtName.Text.Trim().Length > 0 ? true : false);
returnType = (cmbSalesLedger.SelectedValue == null ? false : true);
returnType = (cmbSalesTax.SelectedValue == null ? false : true);
returnType = (cmbPurchaseLedger.SelectedValue == null ? false : true);
returnType = (cmbPurchaseTax.SelectedValue == null ? false : true);
returnType = (cmbVat.SelectedValue == null ? false : true);
returnType = (cmbServiceTax.SelectedValue == null ? false : true);
return returnType;
}
@@ -147,16 +143,12 @@ namespace Tanshu.Accounts.PointOfSale
product.MinimumLevel = Convert.ToDecimal(txtMinimumLevel.Text);
product.MaximumLevel = Convert.ToDecimal(txtMaximumLevel.Text);
product.Units = cmbUnits.Text;
product.ProductTypeID = new Guid(cmbProductTypes.SelectedValue.ToString());
product.ProductGroupID = new Guid(cmbProductGroups.SelectedValue.ToString());
product.SalePrice = Convert.ToDecimal(txtSalePrice.Text);
if (cmbPurchaseLedger.SelectedValue != null)
product.PurchaseLedgerID = new Guid(cmbPurchaseLedger.SelectedValue.ToString());
product.SaleLedgerID = new Guid(cmbSalesLedger.SelectedValue.ToString());
if (cmbPurchaseTax.SelectedValue != null)
product.PurchaseTaxID = new Guid(cmbPurchaseTax.SelectedValue.ToString());
if (cmbServiceTax.SelectedValue != null)
product.ServiceTaxID = new Guid(cmbServiceTax.SelectedValue.ToString());
product.Discontinued = chkDiscontinued.Checked;
product.PurchasePrice = Convert.ToDecimal(txtPurchasePrice.Text);
product.SaleTaxID = new Guid(cmbSalesTax.SelectedValue.ToString());
product.VatID = new Guid(cmbVat.SelectedValue.ToString());
if (addNew)
new ProductBI().Insert(product);
else
@@ -194,11 +186,11 @@ namespace Tanshu.Accounts.PointOfSale
private void btnAddCategory_Click(object sender, EventArgs e)
{
ProductTypes frm = new ProductTypes();
ProductGroups frm = new ProductGroups();
frm.ShowDialog();
frm.Dispose();
FillCombos();
cmbProductTypes.SelectedIndex = 0;
cmbProductGroups.SelectedIndex = 0;
}
@@ -126,18 +126,12 @@
<metadata name="bsUnits.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>123, 17</value>
</metadata>
<metadata name="bsSalesLedgers.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 54</value>
</metadata>
<metadata name="bsSalesTax.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<metadata name="bsVat.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>145, 54</value>
</metadata>
<metadata name="bsPurchaseTax.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<metadata name="bsServiceTax.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>438, 54</value>
</metadata>
<metadata name="bsPurchaseLedgers.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>273, 54</value>
</metadata>
<metadata name="$this.TrayHeight" type="System.Int32, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>102</value>
</metadata>
@@ -217,7 +217,7 @@ namespace Tanshu.Accounts.PointOfSale
return;
else
{
SetQuantity(product, amount / (product.Price * (1 + product.Tax) * (1 - product.Discount)), true, false, bindingSource, bill);
SetQuantity(product, amount / (product.Price * (1 + product.Vat + product.ServiceTax) * (1 - product.Discount)), true, false, bindingSource, bill);
}
}
#endregion
+1 -36
View File
@@ -28,7 +28,6 @@
/// </summary>
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
this.chkImportant = new System.Windows.Forms.CheckBox();
this.txtRemarks = new System.Windows.Forms.TextBox();
this.label6 = new System.Windows.Forms.Label();
@@ -36,9 +35,6 @@
this.label4 = new System.Windows.Forms.Label();
this.txtPhone = new System.Windows.Forms.TextBox();
this.txtAddress = new System.Windows.Forms.TextBox();
this.label3 = new System.Windows.Forms.Label();
this.cmbLedger = new System.Windows.Forms.ComboBox();
this.bsLedgers = new System.Windows.Forms.BindingSource(this.components);
this.label2 = new System.Windows.Forms.Label();
this.txtName = new System.Windows.Forms.TextBox();
this.btnSave = new System.Windows.Forms.Button();
@@ -46,7 +42,6 @@
this.btnCancel = new System.Windows.Forms.Button();
this.Label1 = new System.Windows.Forms.Label();
this.txtUniqueID = new System.Windows.Forms.TextBox();
((System.ComponentModel.ISupportInitialize)(this.bsLedgers)).BeginInit();
this.SuspendLayout();
//
// chkImportant
@@ -110,31 +105,6 @@
this.txtAddress.Size = new System.Drawing.Size(292, 85);
this.txtAddress.TabIndex = 2;
//
// label3
//
this.label3.AutoSize = true;
this.label3.Location = new System.Drawing.Point(35, 67);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(40, 13);
this.label3.TabIndex = 10;
this.label3.Text = "Ledger";
//
// cmbLedger
//
this.cmbLedger.DataSource = this.bsLedgers;
this.cmbLedger.DisplayMember = "Name";
this.cmbLedger.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.cmbLedger.FormattingEnabled = true;
this.cmbLedger.Location = new System.Drawing.Point(81, 64);
this.cmbLedger.Name = "cmbLedger";
this.cmbLedger.Size = new System.Drawing.Size(292, 21);
this.cmbLedger.TabIndex = 15;
this.cmbLedger.ValueMember = "LedgerID";
//
// bsLedgers
//
this.bsLedgers.DataSource = typeof(Tanshu.Accounts.Contracts.LedgerBO);
//
// label2
//
this.label2.AutoSize = true;
@@ -172,6 +142,7 @@
// btnCancel
//
this.btnCancel.AccessibleName = "Done";
this.btnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
this.btnCancel.Location = new System.Drawing.Point(301, 315);
this.btnCancel.Name = "btnCancel";
this.btnCancel.Size = new System.Drawing.Size(72, 24);
@@ -220,8 +191,6 @@
this.Controls.Add(this.label4);
this.Controls.Add(this.txtPhone);
this.Controls.Add(this.txtAddress);
this.Controls.Add(this.label3);
this.Controls.Add(this.cmbLedger);
this.Controls.Add(this.label2);
this.Controls.Add(this.txtName);
this.MaximizeBox = false;
@@ -230,7 +199,6 @@
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "Customers";
this.Load += new System.EventHandler(this.CustomersForm_Load);
((System.ComponentModel.ISupportInitialize)(this.bsLedgers)).EndInit();
this.ResumeLayout(false);
this.PerformLayout();
@@ -245,14 +213,11 @@
private System.Windows.Forms.Label label4;
private System.Windows.Forms.TextBox txtPhone;
private System.Windows.Forms.TextBox txtAddress;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.ComboBox cmbLedger;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.TextBox txtName;
internal System.Windows.Forms.Button btnSave;
internal System.Windows.Forms.Button btnDelete;
internal System.Windows.Forms.Button btnCancel;
private System.Windows.Forms.BindingSource bsLedgers;
internal System.Windows.Forms.Label Label1;
internal System.Windows.Forms.TextBox txtUniqueID;
}
@@ -23,13 +23,11 @@ namespace Tanshu.Accounts.PointOfSale
}
private void CustomersForm_Load(object sender, EventArgs e)
{
bsLedgers.DataSource = new CustomerBI().GetCustomerLedgers();
if (customerID.HasValue)
{
customer = new CustomerBI().GetCustomer(customerID.Value);
btnDelete.Enabled = true;
txtName.Text = customer.Name;
cmbLedger.SelectedValue = customer.LedgerID;
txtPhone.Text = customer.Phone;
txtAddress.Text = customer.Address;
txtRemarks.Text = customer.Remarks;
@@ -71,12 +69,7 @@ namespace Tanshu.Accounts.PointOfSale
private bool ValidateValues()
{
bool returnType = true;
if (txtName.Text.Trim().Length > 0)
{
if (cmbLedger.SelectedValue == null)
return false;
}
else
if (txtName.Text.Trim().Length == 0)
return false;
return returnType;
}
@@ -86,7 +79,6 @@ namespace Tanshu.Accounts.PointOfSale
customer = new CustomerBO();
UserBO user = CurrentUser.user;
customer.Name = txtName.Text;
customer.LedgerID = (Guid)cmbLedger.SelectedValue;
customer.Phone = txtPhone.Text;
customer.Address = txtAddress.Text;
customer.Remarks = txtRemarks.Text;
@@ -117,10 +117,4 @@
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="bsLedgers.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
<metadata name="bsLedgers.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
</root>
@@ -50,14 +50,9 @@ namespace Tanshu.Accounts.PointOfSale
}
decimal freeSale = 0, voids = 0, pending = 0, net = 0, tax = 0;
new SalesAnalysisBI().GetAdditionalInfo(ref freeSale, ref voids, ref pending, ref net, ref tax, startDate, finishDate);
decimal freeSale = new SalesAnalysisBI().GetFreeSale(startDate, finishDate);
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);
txtFreeSale.Text = String.Format("{0:#,##0.00;(#,##0.00);0}", freeSale);
}
private void dtpFinish_ValueChanged(object sender, EventArgs e)
@@ -75,7 +70,7 @@ namespace Tanshu.Accounts.PointOfSale
private void dgvSale_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
{
if (!_details.HasValue)
_details = ((SalesAnalysisBO)dgvSale.SelectedRows[0].DataBoundItem).TypeID;
_details = ((SalesAnalysisBO)dgvSale.SelectedRows[0].DataBoundItem).ProductGroupID;
else
_details = null;
ShowStatement();
+10 -102
View File
@@ -28,16 +28,8 @@
/// </summary>
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.txtPending = new System.Windows.Forms.TextBox();
this.txtVoid = new System.Windows.Forms.TextBox();
this.label5 = new System.Windows.Forms.Label();
this.txtFreeSale = new System.Windows.Forms.TextBox();
this.label4 = new System.Windows.Forms.Label();
this.label3 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.label1 = 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();
@@ -46,54 +38,13 @@
((System.ComponentModel.ISupportInitialize)(this.dgvSale)).BeginInit();
this.SuspendLayout();
//
// txtNet
// txtFreeSale
//
this.txtNet.Location = new System.Drawing.Point(224, 487);
this.txtNet.Name = "txtNet";
this.txtNet.ReadOnly = true;
this.txtNet.Size = new System.Drawing.Size(100, 20);
this.txtNet.TabIndex = 17;
//
// txtTax
//
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;
//
// txtGross
//
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;
//
// txtPending
//
this.txtPending.Location = new System.Drawing.Point(118, 487);
this.txtPending.Name = "txtPending";
this.txtPending.ReadOnly = true;
this.txtPending.Size = new System.Drawing.Size(100, 20);
this.txtPending.TabIndex = 16;
//
// txtVoid
//
this.txtVoid.Location = new System.Drawing.Point(12, 487);
this.txtVoid.Name = "txtVoid";
this.txtVoid.ReadOnly = true;
this.txtVoid.Size = new System.Drawing.Size(100, 20);
this.txtVoid.TabIndex = 15;
//
// label5
//
this.label5.AutoSize = true;
this.label5.Location = new System.Drawing.Point(115, 471);
this.label5.Name = "label5";
this.label5.Size = new System.Drawing.Size(70, 13);
this.label5.TabIndex = 24;
this.label5.Text = "Pending Sale";
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
//
@@ -102,34 +53,7 @@
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(52, 13);
this.label4.TabIndex = 23;
this.label4.Text = "Void Sale";
//
// label3
//
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.TabIndex = 26;
this.label3.Text = "Tax";
//
// 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.TabIndex = 27;
this.label2.Text = "Gross Sale";
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(221, 471);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(48, 13);
this.label1.TabIndex = 25;
this.label1.Text = "Net Sale";
this.label4.Text = "Free Sale";
//
// dgvSale
//
@@ -194,16 +118,8 @@
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.txtPending);
this.Controls.Add(this.txtVoid);
this.Controls.Add(this.label5);
this.Controls.Add(this.txtFreeSale);
this.Controls.Add(this.label4);
this.Controls.Add(this.label3);
this.Controls.Add(this.label2);
this.Controls.Add(this.label1);
this.Controls.Add(this.dgvSale);
this.Controls.Add(this.dtpFinish);
this.Controls.Add(this.dtpStart);
@@ -221,16 +137,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 txtPending;
private System.Windows.Forms.TextBox txtVoid;
private System.Windows.Forms.Label label5;
private System.Windows.Forms.TextBox txtFreeSale;
private System.Windows.Forms.Label label4;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.DataGridView dgvSale;
private System.Windows.Forms.DateTimePicker dtpFinish;
private System.Windows.Forms.DateTimePicker dtpStart;
@@ -262,7 +262,7 @@ namespace Tanshu.Accounts.PointOfSale
}
private void CalculateAmount()
{
txtGrossTax.Text = string.Format("{0:#0.00}", bill.Values.Sum(b => b.TaxAmount));
txtGrossTax.Text = string.Format("{0:#0.00}", bill.Values.Sum(b => b.TotalTax));
txtDiscount.Text = string.Format("{0:#0.00}", bill.Values.Sum(b => b.DiscountAmount));
txtGrossAmount.Text = string.Format("{0:#0.00}", bill.Values.Sum(b => b.GrossAmount));
txtAmount.Text = string.Format("{0:#0.00}", Math.Round(bill.Values.Sum(b => b.Value)));
@@ -424,8 +424,6 @@ namespace Tanshu.Accounts.PointOfSale
Printed = finalBill,
Date = DateTime.Now,
Narration = txtNarration.Text,
Ref = "",
Type = 'S',
UserID = user.UserID,
Floor = _floor,
AdvanceID = _advanceID
@@ -448,14 +446,11 @@ namespace Tanshu.Accounts.PointOfSale
var saleVoucher = new SaleVoucherBO
{
VoucherID = _billInfo.VoucherID,
timestamp = _billInfo.timestamp,
UserID = _billInfo.UserID,
Date = _billInfo.Date,
CreationDate = DateTime.Now,
LastEditDate = DateTime.Now,
Narration = _billInfo.Narration,
Ref = "",
Type = 'S',
Alarm = _billInfo.Alarm,
BillID = _billInfo.BillID,
CustomerID = customer.CustomerID,
@@ -465,7 +460,6 @@ namespace Tanshu.Accounts.PointOfSale
TableID = txtTableID.Text,
VoidReason = _billInfo.VoidReason,
WaiterID = (Guid)btnWaiter.Tag,
SaleTimestamp = _billInfo.SaleTimestamp,
Floor = _floor,
AdvanceID = _advanceID
};
@@ -533,7 +527,8 @@ namespace Tanshu.Accounts.PointOfSale
Price = inventory.Rate,
Printed = inventory.Quantity,
Quantity = inventory.Quantity,
Tax = inventory.Tax,
Vat = inventory.Vat,
ServiceTax = inventory.ServiceTax
});
}
CalculateAmount();
@@ -176,11 +176,11 @@
<Compile Include="ProductsForm.Designer.cs">
<DependentUpon>ProductsForm.cs</DependentUpon>
</Compile>
<Compile Include="ProductTypes.cs">
<Compile Include="ProductGroups.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="ProductTypes.Designer.cs">
<DependentUpon>ProductTypes.cs</DependentUpon>
<Compile Include="ProductGroups.Designer.cs">
<DependentUpon>ProductGroups.cs</DependentUpon>
</Compile>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
@@ -244,8 +244,8 @@
<DependentUpon>ProductsForm.cs</DependentUpon>
<SubType>Designer</SubType>
</EmbeddedResource>
<EmbeddedResource Include="ProductTypes.resx">
<DependentUpon>ProductTypes.cs</DependentUpon>
<EmbeddedResource Include="ProductGroups.resx">
<DependentUpon>ProductGroups.cs</DependentUpon>
<SubType>Designer</SubType>
</EmbeddedResource>
<EmbeddedResource Include="Sales\RecieveAdvanceForm.resx">
@@ -55,7 +55,7 @@ namespace Tanshu.Accounts.PointOfSale
string query = @"
SELECT ISNULL(SUM(i.Amount), 0) FROM {0}.dbo.Vouchers t INNER JOIN {0}.dbo.SaleVoucher s ON t.VoucherID = s.VoucherID
INNER JOIN {0}.dbo.Inventory i ON t.VoucherID = i.VoucherID
WHERE t.Type = 'S' AND t.Date BETWEEN @StartDate AND @FinishDate AND s.Void = 0 AND s.Paid = 1
WHERE t.Date BETWEEN @StartDate AND @FinishDate AND s.Void = 0 AND s.Paid = 1
AND i.Tax = @Tax
";
using (SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["connection"].ConnectionString))
+18 -10
View File
@@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Linq;
using Tanshu.Accounts.Contracts;
using Tanshu.Accounts.BI;
using System.Windows.Forms;
namespace Tanshu.Accounts.Print
{
@@ -96,7 +97,7 @@ namespace Tanshu.Accounts.Print
billText += "\n\r" + "------------------------------------------";
foreach (var item in billItems)
{
if (Math.Round((item.Rate * (1 + item.Tax)), 0) == 1)
if (Math.Round((item.Rate * (1 + item.Vat + item.ServiceTax)), 0) == 1)
{
billText += "\n\r" + " ";
billText += FormatText(item.ProductName, 22, false, Align.Left) + " ";
@@ -113,10 +114,14 @@ namespace Tanshu.Accounts.Print
}
billText += "\n\r" + "------------------------------------------";
decimal amount = billItems.Sum(b => b.Tax * b.Quantity * b.Rate * (1 - b.Discount));
decimal amount = billItems.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));
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);
if (amount != 0)
billText += "\n\r" + FormatText("Discount : ", 33, false, Align.Right) + FormatBillNum(amount, 9);
@@ -128,7 +133,7 @@ namespace Tanshu.Accounts.Print
billText += "\n\r" + FormatText("Less Advance : ", 33, false, Align.Right) + FormatBillNum(advance, 9);
}
amount = billItems.Sum(b => (1 + b.Tax) * b.Quantity * b.Rate * (1 - b.Discount)) - advance;
amount = billItems.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;
@@ -188,12 +193,17 @@ namespace Tanshu.Accounts.Print
private static bool PrintRaw(string text, string documentName)
{
#if (DEBUG)
MessageBox.Show(text,documentName);
return true;
#else
var printerName = System.Configuration.ConfigurationManager.AppSettings["Printer"].Trim();
if (!RawPrinterHelper.PrintString(printerName, documentName, text, new char[] { ';' }))
{
System.Windows.Forms.MessageBox.Show("Error in PrintRAW Function. Please Report immediately");
}
return true;
#endif
}
#region Print Cash Total
@@ -232,17 +242,16 @@ namespace Tanshu.Accounts.Print
printText += DrawLine;
foreach (var d in det)
{
if (d.Section.Length > 30)
d.Section = d.Section.Substring(0, 30);
if (d.Gross != 0)
if (d.Name.Length > 30)
d.Name = d.Name.Substring(0, 30);
if (d.Vat != 0 || d.ServiceTax != 0)
{
printText += string.Format("\n\r{0,-22} {1,9:#,##0} {2,9:#,##0}", d.Section, d.Net, d.Gross);
printText += string.Format("\n\r{0,-17} {1,8:#,##0} {2,7:#,##0} {3,7:#,##0}", d.Name, d.Net, d.Vat, d.ServiceTax);
}
else
{
printText += string.Format("\n\r{0,-32} {1,9:#,##0}", d.Section, d.Net);
printText += string.Format("\n\r{0,-32} {1,9:#,##0}", d.Name, d.Net);
}
printText += DrawLine;
}
printText += DrawEqual;
printText += CutPrinter;
@@ -259,7 +268,6 @@ namespace Tanshu.Accounts.Print
foreach (var d in det)
{
printText += string.Format("\n\r{0,-23} {1,9:#,##0.00} {2,8:#,##0}", d.Product, d.Quantity, d.Amount);
printText += DrawLine;
}
printText += DrawEqual;
printText += CutPrinter;
+6 -12
View File
@@ -27,8 +27,7 @@ namespace Tanshu.Accounts.SqlDAO
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.Type = 'S'
AND t.LastEditDate BETWEEN @StartDate AND @FinishDate AND t.UserID = @UserID
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
";
@@ -204,8 +203,7 @@ SELECT DISTINCT CashierOut FROM Advances WHERE DateOut BETWEEN @StartDate AND @F
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.Type = 'S'
AND t.LastEditDate BETWEEN @StartDate AND @FinishDate AND t.UserID = @UserID
WHERE t.LastEditDate BETWEEN @StartDate AND @FinishDate AND t.UserID = @UserID
AND s.PaidStatus != @Pending AND s.PaidStatus != @Void
";
using (var cmd = new SqlCommand(query))
@@ -232,8 +230,7 @@ INNER JOIN Customers c ON s.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
WHERE v.Type = 'S'
AND v.LastEditDate BETWEEN @StartDate AND @FinishDate AND v.UserID = @UserID
WHERE v.LastEditDate BETWEEN @StartDate AND @FinishDate AND v.UserID = @UserID
AND s.PaidStatus != @Void
AND i.Discount >= .05
)
@@ -269,8 +266,7 @@ GROUP BY v.Date, s.BillID, c.Name
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 t.Type = 'S'
AND s.PaidStatus = @Pending
WHERE s.PaidStatus = @Pending
AND t.LastEditDate < @StartDate AND t.UserID = @UserID
";
using (var cmd = new SqlCommand(query))
@@ -287,8 +283,7 @@ AND t.LastEditDate < @StartDate AND t.UserID = @UserID
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 t.Type = 'S'
AND s.PaidStatus != @Pending AND s.PaidStatus != @Void
WHERE s.PaidStatus != @Pending AND s.PaidStatus != @Void
AND t.CreationDate < @StartDate AND t.LastEditDate >= @StartDate AND t.UserID = @UserID
";
using (var cmd = new SqlCommand(query))
@@ -306,8 +301,7 @@ AND t.CreationDate < @StartDate AND t.LastEditDate >= @StartDate AND t.UserID =
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 t.Type = 'S'
AND s.PaidStatus = @Void
WHERE s.PaidStatus = @Void
AND t.CreationDate < @StartDate AND t.LastEditDate >= @StartDate AND t.UserID = @UserID
";
using (var cmd = new SqlCommand(query))
+5 -11
View File
@@ -18,7 +18,7 @@ namespace Tanshu.Accounts.SqlDAO
using (SqlCommand cmd = new SqlCommand(@"
SET @CustomerID = NEWID();
SELECT @Code = ISNULL(MAX(Code), 0) + 1 FROM Customers;
INSERT INTO Customers (CustomerID, Code, Name, LedgerID, Address, Important, Phone, Remarks) VALUES (@CustomerID, @Code, @Name, @LedgerID, @Address, @Important, @Phone, @Remarks)"))
INSERT INTO Customers (CustomerID, Code, Name, Address, Important, Phone, Remarks) VALUES (@CustomerID, @Code, @Name, @Address, @Important, @Phone, @Remarks)"))
{
cmd.Parameters.Add("@CustomerID", System.Data.SqlDbType.UniqueIdentifier);
cmd.Parameters["@CustomerID"].Direction = System.Data.ParameterDirection.Output;
@@ -26,7 +26,6 @@ INSERT INTO Customers (CustomerID, Code, Name, LedgerID, Address, Important, Pho
cmd.Parameters["@Code"].Direction = System.Data.ParameterDirection.Output;
cmd.Parameters.AddWithValue("@Name", customer.Name);
cmd.Parameters.AddWithValue("@LedgerID", customer.LedgerID);
cmd.Parameters.AddWithValue("@Address", customer.Address);
cmd.Parameters.AddWithValue("@Important", customer.Important);
cmd.Parameters.AddWithValue("@Phone", customer.Phone);
@@ -38,12 +37,11 @@ INSERT INTO Customers (CustomerID, Code, Name, LedgerID, Address, Important, Pho
}
public void Update(CustomerBO customer)
{
using (SqlCommand cmd = new SqlCommand(@"UPDATE Customers SET Code = @Code, Name = @Name, LedgerID = @LedgerID, Address = @Address, Important = @Important, Phone = @Phone, Remarks = @Remarks WHERE CustomerID = @CustomerID"))
using (SqlCommand cmd = new SqlCommand(@"UPDATE Customers SET Code = @Code, Name = @Name, Address = @Address, Important = @Important, Phone = @Phone, Remarks = @Remarks WHERE CustomerID = @CustomerID"))
{
cmd.Parameters.AddWithValue("@CustomerID", customer.CustomerID);
cmd.Parameters.AddWithValue("@Code", customer.Code);
cmd.Parameters.AddWithValue("@Name", customer.Name);
cmd.Parameters.AddWithValue("@LedgerID", customer.LedgerID);
cmd.Parameters.AddWithValue("@Address", customer.Address);
cmd.Parameters.AddWithValue("@Important", customer.Important);
cmd.Parameters.AddWithValue("@Phone", customer.Phone);
@@ -72,7 +70,7 @@ INSERT INTO Customers (CustomerID, Code, Name, LedgerID, Address, Important, Pho
string[] filters = filter["Universal"].Split(' ');
if ((filters != null) && (filters.Length > 0))
{
query = "SELECT CustomerID, Code, Name, LedgerID, Address, Important, Phone, Remarks FROM Customers WHERE ";
query = "SELECT CustomerID, Code, Name, Address, Important, Phone, Remarks FROM Customers WHERE ";
foreach (string fil in filters)
{
query += string.Format("(Name LIKE '%{0}%' OR Address LIKE '%{0}%' OR Phone LIKE '%{0}%' OR Remarks LIKE '%{0}%') AND ", fil);
@@ -81,14 +79,10 @@ INSERT INTO Customers (CustomerID, Code, Name, LedgerID, Address, Important, Pho
}
else
{
query = "SELECT CustomerID, Code, Name, LedgerID, Address, Important, Phone, Remarks FROM Customers";
query = "SELECT CustomerID, Code, Name, Address, Important, Phone, Remarks FROM Customers";
}
return BusinessObjectDAO<CustomerBO>.GetBusinessObjects(connection.ExecuteReader(query));
}
public List<LedgerBO> GetCustomerLedgers()
{
return BusinessObjectDAO<LedgerBO>.GetBusinessObjects(connection.ExecuteReader("SELECT * FROM Ledgers WHERE Type IN ('B', 'D') ORDER BY Name"));
}
public List<CustomerBO> GetCustomers()
{
Dictionary<string, string> filter = new Dictionary<string, string>();
@@ -97,7 +91,7 @@ INSERT INTO Customers (CustomerID, Code, Name, LedgerID, Address, Important, Pho
}
public List<CustomerBO> GetCustomers(Guid customerID)
{
string query = "SELECT CustomerID, Code, Name, LedgerID, Address, Important, Phone, Remarks FROM Customers WHERE CustomerID = @CustomerID";
string query = "SELECT CustomerID, Code, Name, Address, Important, Phone, Remarks FROM Customers WHERE CustomerID = @CustomerID";
using (SqlCommand cmd = new SqlCommand(query))
{
cmd.Parameters.AddWithValue("@CustomerID", customerID);
+9 -23
View File
@@ -17,57 +17,43 @@ namespace Tanshu.Accounts.SqlDAO
{
using (SqlCommand cmd = new SqlCommand(@"
SET @InventoryID = NEWID();
INSERT INTO Inventory (InventoryID, VoucherID, ProductID, ComplexProductID, Quantity, Rate, Tax, Discount, IsRateFinal) VALUES (@InventoryID, @VoucherID, @ProductID, @ComplexProductID, @Quantity, @Rate, @Tax, @Discount, @IsRateFinal);
SELECT @timestamp = timestamp, @Amount = Amount FROM Inventory WHERE InventoryID = @InventoryID;
INSERT INTO Inventory (InventoryID, VoucherID, ProductID, Quantity, Rate, Vat, ServiceTax, Discount) VALUES (@InventoryID, @VoucherID, @ProductID, @Quantity, @Rate, @Vat, @ServiceTax, @Discount);
SELECT @Amount = Amount FROM Inventory WHERE InventoryID = @InventoryID;
"))
{
cmd.Parameters.Add("@InventoryID", System.Data.SqlDbType.UniqueIdentifier);
cmd.Parameters["@InventoryID"].Direction = System.Data.ParameterDirection.Output;
cmd.Parameters.AddWithValue("@VoucherID", inventory.VoucherID);
cmd.Parameters.AddWithValue("@ProductID", inventory.ProductID);
if (inventory.ComplexProductID.HasValue)
cmd.Parameters.AddWithValue("@ComplexProductID", inventory.ComplexProductID);
else
cmd.Parameters.AddWithValue("@ComplexProductID", DBNull.Value);
cmd.Parameters.AddWithValue("@Quantity", inventory.Quantity);
cmd.Parameters.AddWithValue("@Rate", inventory.Rate);
cmd.Parameters.AddWithValue("@Tax", inventory.Tax);
cmd.Parameters.AddWithValue("@Vat", inventory.Vat);
cmd.Parameters.AddWithValue("@ServiceTax", inventory.ServiceTax);
cmd.Parameters.AddWithValue("@Discount", inventory.Discount);
cmd.Parameters.Add("@Amount", System.Data.SqlDbType.Decimal);
cmd.Parameters["@Amount"].Direction = System.Data.ParameterDirection.Output;
cmd.Parameters.AddWithValue("@IsRateFinal", inventory.IsRateFinal);
cmd.Parameters.Add("@timestamp", System.Data.SqlDbType.Timestamp);
cmd.Parameters["@timestamp"].Direction = System.Data.ParameterDirection.Output;
connection.ExecuteNonQuery(cmd);
inventory.InventoryID = (Guid)cmd.Parameters["@InventoryID"].Value;
inventory.timestamp = (byte[])cmd.Parameters["@timestamp"].Value;
return true;
}
}
public bool Update(InventoryBO inventory)
{
using (SqlCommand cmd = new SqlCommand(@"
UPDATE Inventory SET VoucherID = @VoucherID, ProductID = @ProductID, ComplexProductID = @ComplexProductID, Quantity = @Quantity, Rate = @Rate, Tax = @Tax, Discount = @Discount, IsRateFinal = @IsRateFinal WHERE InventoryID = @InventoryID;
SELECT @timestamp = timestamp, @Amount = Amount FROM Inventory WHERE InventoryID = @InventoryID;"))
UPDATE Inventory SET VoucherID = @VoucherID, ProductID = @ProductID, Quantity = @Quantity, Rate = @Rate, Vat = @Vat, ServiceTax = @ServiceTax, Discount = @Discount WHERE InventoryID = @InventoryID;
SELECT @Amount = Amount FROM Inventory WHERE InventoryID = @InventoryID;"))
{
cmd.Parameters.AddWithValue("@InventoryID", inventory.InventoryID);
cmd.Parameters.AddWithValue("@VoucherID", inventory.VoucherID);
cmd.Parameters.AddWithValue("@ProductID", inventory.ProductID);
if (inventory.ComplexProductID.HasValue)
cmd.Parameters.AddWithValue("@ComplexProductID", inventory.ComplexProductID);
else
cmd.Parameters.AddWithValue("@ComplexProductID", DBNull.Value);
cmd.Parameters.AddWithValue("@Quantity", inventory.Quantity);
cmd.Parameters.AddWithValue("@Rate", inventory.Rate);
cmd.Parameters.AddWithValue("@Tax", inventory.Tax);
cmd.Parameters.AddWithValue("@Vat", inventory.Vat);
cmd.Parameters.AddWithValue("@ServiceTax", inventory.ServiceTax);
cmd.Parameters.AddWithValue("@Discount", inventory.Discount);
cmd.Parameters.Add("@Amount", System.Data.SqlDbType.Decimal);
cmd.Parameters["@Amount"].Direction = System.Data.ParameterDirection.Output;
cmd.Parameters.AddWithValue("@IsRateFinal", inventory.IsRateFinal);
cmd.Parameters.Add("@timestamp", System.Data.SqlDbType.Timestamp);
cmd.Parameters["@timestamp"].Direction = System.Data.ParameterDirection.Output;
connection.ExecuteNonQuery(cmd);
inventory.timestamp = (byte[])cmd.Parameters["@timestamp"].Value;
return true;
}
}
@@ -93,7 +79,7 @@ SELECT @timestamp = timestamp, @Amount = Amount FROM Inventory WHERE InventoryID
public List<InventoryDisplayBO> 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 ORDER BY timestamp");
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));
}
-101
View File
@@ -1,101 +0,0 @@
using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using Tanshu.Accounts.Contracts;
using Tanshu.Data.DAO;
namespace Tanshu.Accounts.SqlDAO
{
public class LedgerDAO : BaseDAO
{
public LedgerDAO(IConnectionDAO connection)
: base(connection)
{ }
public bool Insert(LedgerBO ledger)
{
ledger.LedgerID = Guid.NewGuid();
using (SqlCommand cmd = new SqlCommand(@"
SELECT @Code = ISNULL(MAX(Code),0) + 1 FROM Ledgers WHERE Type = @Type;
INSERT INTO Ledgers (LedgerID, Code, Name, Type, ParentLedgerID, CostCenterID) VALUES (@LedgerID, @Code, @Name, @Type, @ParentLedgerID, @CostCenterID);
SELECT @timestamp = timestamp FROM Ledgers WHERE LedgerID = @LedgerID;
"))
{
cmd.Parameters.AddWithValue("@LedgerID", ledger.LedgerID);
cmd.Parameters.Add("@Code", System.Data.SqlDbType.Int);
cmd.Parameters["@Code"].Direction = System.Data.ParameterDirection.Output;
cmd.Parameters.AddWithValue("@Name", ledger.Name);
cmd.Parameters.AddWithValue("@Type", ledger.Type);
if (ledger.ParentLedgerID != new Guid())
cmd.Parameters.AddWithValue("@ParentLedgerID", ledger.ParentLedgerID);
else
cmd.Parameters.AddWithValue("@ParentLedgerID", DBNull.Value);
cmd.Parameters.AddWithValue("@CostCenterID", ledger.CostCenterID);
cmd.Parameters.Add("@timestamp", System.Data.SqlDbType.Timestamp);
cmd.Parameters["@timestamp"].Direction = System.Data.ParameterDirection.Output;
connection.ExecuteNonQuery(cmd);
ledger.Code = (int)cmd.Parameters["@Code"].Value;
ledger.timestamp = (byte[])cmd.Parameters["@timestamp"].Value;
return true;
}
}
public LedgerBO GetLedger(Guid ledgerID)
{
SqlCommand cmd = new SqlCommand("SELECT * FROM Ledgers WHERE LedgerID = @LedgerID");
cmd.Parameters.AddWithValue("@LedgerID", ledgerID);
return BusinessObjectDAO<LedgerBO>.GetBusinessObject(connection.ExecuteReader(cmd));
}
public LedgerBO GetLedger(string name)
{
SqlCommand cmd = new SqlCommand("SELECT * FROM Ledgers WHERE Name = @Name");
cmd.Parameters.AddWithValue("@Name", name);
return BusinessObjectDAO<LedgerBO>.GetBusinessObject(connection.ExecuteReader(cmd));
}
public List<LedgerDisplayBO> GetLedgers(char type)
{
SqlCommand cmd = new SqlCommand("SELECT c.Name as CostCenter, l.* FROM CostCenters c INNER JOIN Ledgers l ON c.CostCenterID = l.CostCenterID WHERE Type = @Type");
cmd.Parameters.AddWithValue("@Type", type);
return BusinessObjectDAO<LedgerDisplayBO>.GetBusinessObjects(connection.ExecuteReader(cmd));
}
public bool Delete(Guid ledgerID)
{
using (SqlCommand cmd = new SqlCommand("DELETE FROM Ledgers WHERE LedgerID = @LedgerID"))
{
cmd.Parameters.AddWithValue("@LedgerID", ledgerID);
connection.ExecuteNonQuery(cmd);
return true;
}
}
public bool Update(LedgerBO ledger)
{
using (SqlCommand cmd = new SqlCommand(@"
UPDATE Ledgers SET Code = @Code, Name = @Name, Type = @Type, ParentLedgerID = @ParentLedgerID, CostCenterID = @CostCenterID WHERE LedgerID = @LedgerID
SELECT @timestamp = timestamp FROM Ledgers WHERE LedgerID = @LedgerID;
"))
{
cmd.Parameters.AddWithValue("@LedgerID", ledger.LedgerID);
cmd.Parameters.AddWithValue("@Code", ledger.Code);
cmd.Parameters.AddWithValue("@Name", ledger.Name);
cmd.Parameters.AddWithValue("@Type", ledger.Type);
if (ledger.ParentLedgerID != new Guid())
cmd.Parameters.AddWithValue("@ParentLedgerID", ledger.ParentLedgerID);
else
cmd.Parameters.AddWithValue("@ParentLedgerID", DBNull.Value);
cmd.Parameters.AddWithValue("@CostCenterID", ledger.CostCenterID);
cmd.Parameters.Add("@timestamp", System.Data.SqlDbType.Timestamp);
cmd.Parameters["@timestamp"].Direction = System.Data.ParameterDirection.Output;
connection.ExecuteNonQuery(cmd);
ledger.timestamp = (byte[])cmd.Parameters["@timestamp"].Value;
return true;
}
}
public List<LedgerDisplayBO> GetLedgers()
{
string query = "SELECT c.Name as CostCenter, l.* FROM CostCenters c INNER JOIN Ledgers l ON c.CostCenterID = l.CostCenterID WHERE Type <> 'S'";
return BusinessObjectDAO<LedgerDisplayBO>.GetBusinessObjects(connection.ExecuteReader(query));
}
}
}
+5 -5
View File
@@ -25,14 +25,14 @@ namespace Tanshu.Accounts.SqlDAO
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.Type = 'S' AND t.Date BETWEEN @StartDate AND @FinishDate AND s.PaidStatus IN (2, 3)
WHERE t.Date BETWEEN @StartDate AND @FinishDate AND s.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.Type = 'S' AND t.Date BETWEEN @StartDate AND @FinishDate AND s.PaidStatus IN (2, 3)
WHERE t.Date BETWEEN @StartDate AND @FinishDate AND s.PaidStatus IN (2, 3)
";
using (var cmd = new SqlCommand(query))
{
@@ -51,7 +51,7 @@ WHERE t.Type = 'S' AND t.Date BETWEEN @StartDate AND @FinishDate AND s.PaidStatu
SELECT DISTINCT v.VoucherID
FROM Vouchers v INNER JOIN SaleVoucher s ON v.VoucherID = s.VoucherID
INNER JOIN Inventory i ON v.VoucherID = i.VoucherID
WHERE v.Date BETWEEN @StartDate AND @FinishDate AND v.Type = 'S'
WHERE v.Date BETWEEN @StartDate AND @FinishDate
AND s.PaidStatus = @Cash AND i.Tax = @Tax";
using (var cmd = new SqlCommand(query))
{
@@ -314,8 +314,8 @@ SELECT VoucherID, BillID, TableID, WaiterID, CustomerID, Paid, Void, VoidReason,
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, ComplexProductID, Quantity, Rate, Tax, Discount, IsRateFinal)
SELECT InventoryID, VoucherID, ProductID, ComplexProductID, Quantity, Rate, Tax, Discount, IsRateFinal
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 (
SELECT v.VoucherID FROM {1}.dbo.Vouchers v WHERE v.Date BETWEEN @StartDate AND @EndDate)
";
+21 -55
View File
@@ -20,29 +20,22 @@ namespace Tanshu.Accounts.SqlDAO
product.ProductID = Guid.NewGuid();
SqlCommand cmd = new SqlCommand(@"
SELECT @Code = ISNULL(MAX(Code), 0) + 1 FROM Products;
INSERT INTO Products (ProductID, Code, Name, ShortName, BarCode, Units, ProductTypeID, SaleLedgerID, SaleTaxID ,SalePrice , PurchaseLedgerID ,PurchaseTaxID , PurchasePrice, Discontinued, MinimumLevel, MaximumLevel, SortOrder) VALUES (@ProductID, @Code, @Name, '', '', @Units, @ProductTypeID, @SaleLedgerID, @SaleTaxID, @SalePrice ,@PurchaseLedgerID ,@PurchaseTaxID , @PurchasePrice, @Discontinued, @MinimumLevel, @MaximumLevel, @SortOrder);
SELECT @timestamp = timestamp FROM Products WHERE ProductID = @ProductID;");
INSERT INTO Products (ProductID, Code, Name, ShortName, BarCode, Units, ProductGroupID, VatID ,SalePrice , ServiceTaxID , Discontinued, MinimumLevel, MaximumLevel, SortOrder) VALUES (@ProductID, @Code, @Name, '', '', @Units, @ProductGroupID, @VatID, @SalePrice ,@ServiceTaxID ,@Discontinued, @MinimumLevel, @MaximumLevel, @SortOrder);");
{
cmd.Parameters.AddWithValue("@ProductID", product.ProductID);
cmd.Parameters.Add("@Code", SqlDbType.Int);
cmd.Parameters["@Code"].Direction = ParameterDirection.Output;
cmd.Parameters.AddWithValue("@Name", product.Name);
cmd.Parameters.AddWithValue("@Units", product.Units);
cmd.Parameters.AddWithValue("@ProductTypeID", product.ProductTypeID);
cmd.Parameters.AddWithValue("@SaleLedgerID", product.SaleLedgerID);
cmd.Parameters.AddWithValue("@SaleTaxID", product.SaleTaxID);
cmd.Parameters.AddWithValue("@ProductGroupID", product.ProductGroupID);
cmd.Parameters.AddWithValue("@VatID", product.VatID);
cmd.Parameters.AddWithValue("@SalePrice", product.SalePrice);
cmd.Parameters.AddWithValue("@PurchaseLedgerID", product.PurchaseLedgerID);
cmd.Parameters.AddWithValue("@PurchaseTaxID", product.PurchaseTaxID);
cmd.Parameters.AddWithValue("@PurchasePrice", product.PurchasePrice);
cmd.Parameters.AddWithValue("@ServiceTaxID", product.ServiceTaxID);
cmd.Parameters.AddWithValue("@Discontinued", product.Discontinued);
cmd.Parameters.AddWithValue("@MinimumLevel", product.MinimumLevel);
cmd.Parameters.AddWithValue("@MaximumLevel", product.MaximumLevel);
cmd.Parameters.Add("@timestamp", SqlDbType.Timestamp);
cmd.Parameters.AddWithValue("@SortOrder", product.SortOrder);
cmd.Parameters["@timestamp"].Direction = ParameterDirection.Output;
connection.ExecuteNonQuery(cmd);
product.timestamp = (byte[])cmd.Parameters["@timestamp"].Value;
product.Code = (int)cmd.Parameters["@Code"].Value;
return true;
}
@@ -62,26 +55,20 @@ SELECT @timestamp = timestamp FROM Products WHERE ProductID = @ProductID;");
}
public bool Update(ProductBO product)
{
SqlCommand cmd = new SqlCommand(@"UPDATE Products SET Code = @Code ,Name = @Name ,Units = @Units ,ProductTypeID = @ProductTypeID ,SaleLedgerID = @SaleLedgerID ,SaleTaxID = @SaleTaxID ,SalePrice = @SalePrice ,PurchaseLedgerID = @PurchaseLedgerID ,PurchaseTaxID = @PurchaseTaxID ,PurchasePrice = @PurchasePrice ,Discontinued = @Discontinued ,MinimumLevel = @MinimumLevel ,MaximumLevel = @MaximumLevel, SortOrder=@SortOrder WHERE ProductID = @ProductID SELECT @timestamp = timestamp FROM Products WHERE ProductID = @ProductID;");
SqlCommand cmd = new SqlCommand(@"UPDATE Products SET Code = @Code ,Name = @Name ,Units = @Units ,ProductGroupID = @ProductGroupID ,VatID = @VatID ,SalePrice = @SalePrice ,ServiceTaxID = @ServiceTaxID ,Discontinued = @Discontinued ,MinimumLevel = @MinimumLevel ,MaximumLevel = @MaximumLevel, SortOrder=@SortOrder WHERE ProductID = @ProductID;");
cmd.Parameters.AddWithValue("@ProductID", product.ProductID);
cmd.Parameters.AddWithValue("@Code", product.Code);
cmd.Parameters.AddWithValue("@Name", product.Name);
cmd.Parameters.AddWithValue("@Units", product.Units);
cmd.Parameters.AddWithValue("@ProductTypeID", product.ProductTypeID);
cmd.Parameters.AddWithValue("@SaleLedgerID", product.SaleLedgerID);
cmd.Parameters.AddWithValue("@SaleTaxID", product.SaleTaxID);
cmd.Parameters.AddWithValue("@ProductGroupID", product.ProductGroupID);
cmd.Parameters.AddWithValue("@VatID", product.VatID);
cmd.Parameters.AddWithValue("@SalePrice", product.SalePrice);
cmd.Parameters.AddWithValue("@PurchaseLedgerID", product.PurchaseLedgerID);
cmd.Parameters.AddWithValue("@PurchaseTaxID", product.PurchaseTaxID);
cmd.Parameters.AddWithValue("@PurchasePrice", product.PurchasePrice);
cmd.Parameters.AddWithValue("@ServiceTaxID", product.ServiceTaxID);
cmd.Parameters.AddWithValue("@Discontinued", product.Discontinued);
cmd.Parameters.AddWithValue("@MinimumLevel", product.MinimumLevel);
cmd.Parameters.AddWithValue("@MaximumLevel", product.MaximumLevel);
cmd.Parameters.Add("@timestamp", System.Data.SqlDbType.Timestamp);
cmd.Parameters.AddWithValue("@SortOrder", product.SortOrder);
cmd.Parameters["@timestamp"].Direction = System.Data.ParameterDirection.Output;
connection.ExecuteNonQuery(cmd);
product.timestamp = (byte[])cmd.Parameters["@timestamp"].Value;
return true;
}
public ProductBO GetProduct(string nameAndUnits)
@@ -90,36 +77,10 @@ SELECT @timestamp = timestamp FROM Products WHERE ProductID = @ProductID;");
cmd.Parameters.AddWithValue("@Name", nameAndUnits);
return BusinessObjectDAO<ProductBO>.GetBusinessObject(connection.ExecuteReader(cmd));
}
public decimal GetProductStock(DateTime date, Guid productID, Guid? voucherID)
{
// Add this to get product rate as well
// , CASE WHEN SUM(CASE WHEN t.Type IN ('P', 'Z') THEN i.Quantity ELSE 0 END) = 0 THEN (SELECT PurchasePrice FROM Products p WHERE p.ProductID = i.ProductID) ELSE SUM(CASE WHEN t.Type IN ('P', 'Z') THEN i.Quantity * i.Rate ELSE 0 END) / SUM(CASE WHEN t.Type IN ('P', 'Z') THEN i.Quantity ELSE 0 END) END AS Rate
string query;
if (voucherID.HasValue)
query = @"
SELECT SUM(i.Quantity * j.Debit) AS Quantity
FROM Vouchers t INNER JOIN Inventory i ON t.VoucherID = i.VoucherID INNER JOIN Journal j ON t.VoucherID = j.VoucherID INNER JOIN Products p ON p.ProductID = i.ProductID
WHERE j.CostCenterID = '955F847B-EFDF-4AFA-897C-F0BAF15284A3' AND i.ProductID = @ProductID AND t.Date < @Date
AND t.VoucherID <> @VoucherID
GROUP BY i.ProductID";
else
query = @"
SELECT SUM(i.Quantity * j.Debit) AS Quantity
FROM Vouchers t INNER JOIN Inventory i ON t.VoucherID = i.VoucherID INNER JOIN Journal j ON t.VoucherID = j.VoucherID INNER JOIN Products p ON p.ProductID = i.ProductID
WHERE j.CostCenterID = '955F847B-EFDF-4AFA-897C-F0BAF15284A3' AND i.ProductID = @ProductID AND t.Date < @Date
GROUP BY i.ProductID";
SqlCommand cmd = new SqlCommand(query);
cmd.Parameters.AddWithValue("@Date", date);
cmd.Parameters.AddWithValue("@ProductID", productID);
if (voucherID.HasValue)
cmd.Parameters.AddWithValue("@VoucherID", voucherID.Value);
return (decimal)connection.ExecuteScalar(cmd);
}
public List<ProductDisplayBO> GetProducts()
{
//SELECT p.ProductID, p.Picture, p.Code, p.Name, p.Units, p.ProductTypeID, p.SaleLedgerID, p.SaleTaxID, p.SalePrice, p.PurchaseLedgerID, p.PurchaseTaxID, p.PurchasePrice, p.Discontinued, p.MinimumLevel, p.MaximumLevel, p.timestamp, p.SortOrder, pt.Name AS Type FROM Products p INNER JOIN ProductTypes pt ON p.ProductTypeID = pt.ProductTypeID ORDER BY p.Name
SqlCommand cmd = new SqlCommand("SELECT p.ProductID, p.Picture, p.Code, p.Name, p.Units, p.ProductTypeID, p.SaleLedgerID, p.SaleTaxID, p.SalePrice, p.PurchaseLedgerID, p.PurchaseTaxID, p.PurchasePrice, p.Discontinued, p.MinimumLevel, p.MaximumLevel, p.SortOrder, pt.Name AS Type FROM Products p INNER JOIN ProductTypes pt ON p.ProductTypeID = pt.ProductTypeID ORDER BY p.Name");
//SELECT p.ProductID, p.Picture, p.Code, p.Name, p.Units, p.ProductGroupID, p.VatID, p.SalePrice, p.ServiceTaxID, p.Discontinued, p.MinimumLevel, p.MaximumLevel, 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.MinimumLevel, p.MaximumLevel, 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));
}
@@ -151,8 +112,8 @@ GROUP BY i.ProductID";
SELECT p.ProductID, p.Code, p.Name + ' (' + p.Units + ') ' + ShortName AS Name,
p.SalePrice * (1 + t.Rate) AS Price,
pt.Name AS Category
FROM Products p INNER JOIN Tax t ON p.SaleTaxID = t.TaxID
INNER JOIN ProductTypes pt ON p.ProductTypeID = pt.ProductTypeID
FROM Products p INNER JOIN Tax t ON p.VatID = t.TaxID
INNER JOIN ProductGroups pt ON p.ProductGroupID = pt.ProductGroupID
WHERE pt.IsForSale = 1 AND p.SalePrice > 0 AND p.Discontinued = 0
";
string[] n = filter["Name"].Split(" ".ToCharArray());
@@ -196,10 +157,10 @@ WHERE pt.IsForSale = 1 AND p.SalePrice > 0 AND p.Discontinued = 0
return name;
}
public List<ProductTypeBO> GetProductTypes()
public List<ProductGroupBO> GetProductGroups()
{
SqlCommand cmd = new SqlCommand("SELECT * FROM ProductTypes ORDER BY Name");
return BusinessObjectDAO<ProductTypeBO>.GetBusinessObjects(connection.ExecuteReader(cmd));
SqlCommand cmd = new SqlCommand("SELECT * FROM ProductGroups ORDER BY Name");
return BusinessObjectDAO<ProductGroupBO>.GetBusinessObjects(connection.ExecuteReader(cmd));
}
@@ -208,11 +169,16 @@ WHERE pt.IsForSale = 1 AND p.SalePrice > 0 AND p.Discontinued = 0
string query = @"
WITH ProductsRN AS
(SELECT *, ROW_NUMBER() OVER(ORDER BY Name) AS RowNum FROM Products WHERE Name LIKE '%{0}%')
SELECT TOP {1} p.*, pt.Name AS Type FROM ProductsRN p INNER JOIN ProductTypes pt ON p.ProductTypeID = pt.ProductTypeID WHERE RowNum > {2}
SELECT TOP {1} p.*, pt.Name AS Type FROM ProductsRN p INNER JOIN ProductGroups pt ON p.ProductGroupID = pt.ProductGroupID WHERE RowNum > {2}
";
query = string.Format(query, name, count, skip);
return BusinessObjectDAO<ProductDisplayBO>.GetBusinessObjects(connection.ExecuteReader(query));
}
public List<TaxBO> GetTaxes()
{
return BusinessObjectDAO<TaxBO>.GetBusinessObjects(connection.ExecuteReader("SELECT * FROM Tax;"));
}
}
}
+3 -11
View File
@@ -35,7 +35,6 @@ SELECT @KotID = ISNULL('K-' + CAST(MAX(CAST(SUBSTRING(KotID, 3,8) AS int)) + 1 A
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)
SELECT @timestamp = timestamp FROM [dbo].[SaleVoucher] WHERE VoucherID = @VoucherID
"))
{
cmd.Parameters.AddWithValue("@VoucherID", saleVoucher.VoucherID);
@@ -60,10 +59,7 @@ SELECT @KotID = ISNULL('K-' + CAST(MAX(CAST(SUBSTRING(KotID, 3,8) AS int)) + 1 A
cmd.Parameters.AddWithValue("@Alarm", DBNull.Value);
cmd.Parameters.Add("@KotID", System.Data.SqlDbType.NVarChar, 10);
cmd.Parameters["@KotID"].Direction = System.Data.ParameterDirection.Output;
cmd.Parameters.Add("@timestamp", System.Data.SqlDbType.Timestamp);
cmd.Parameters["@timestamp"].Direction = System.Data.ParameterDirection.Output;
connection.ExecuteNonQuery(cmd);
saleVoucher.SaleTimestamp = (byte[])cmd.Parameters["@timestamp"].Value;
saleVoucher.BillID = (string)cmd.Parameters["@BillID"].Value;
saleVoucher.KotID = (string)cmd.Parameters["@KotID"].Value;
return true;
@@ -106,7 +102,7 @@ IF @Printed = 1 AND (SELECT Printed FROM SaleVoucher WHERE VoucherID = @VoucherI
UPDATE Vouchers SET LastEditDate = GETDATE() WHERE VoucherID = @VoucherID
SELECT @timestamp = timestamp, @KotID = KotID FROM SaleVoucher WHERE VoucherID = @VoucherID
SELECT @KotID = KotID FROM SaleVoucher WHERE VoucherID = @VoucherID
"))
{
cmd.Parameters.AddWithValue("@VoucherID", saleVoucher.VoucherID);
@@ -132,11 +128,7 @@ IF @Printed = 1 AND (SELECT Printed FROM SaleVoucher WHERE VoucherID = @VoucherI
cmd.Parameters.AddWithValue("@Alarm", DBNull.Value);
cmd.Parameters.Add("@KotID", System.Data.SqlDbType.NVarChar, 10);
cmd.Parameters["@KotID"].Direction = System.Data.ParameterDirection.Output;
cmd.Parameters.Add("@timestamp", System.Data.SqlDbType.Timestamp);
cmd.Parameters["@timestamp"].Direction = System.Data.ParameterDirection.Output;
connection.ExecuteNonQuery(cmd);
saleVoucher.timestamp = (byte[])cmd.Parameters["@timestamp"].Value;
saleVoucher.SaleTimestamp = (byte[])cmd.Parameters["@timestamp"].Value;
saleVoucher.BillID = (string)cmd.Parameters["@BillID"].Value;
saleVoucher.KotID = (string)cmd.Parameters["@KotID"].Value;
return true;
@@ -164,13 +156,13 @@ IF @Printed = 1 AND (SELECT Printed FROM SaleVoucher WHERE VoucherID = @VoucherI
}
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, ts.timestamp AS SaleTimestamp FROM SaleVoucher ts INNER JOIN Vouchers b ON ts.VoucherID = b.VoucherID WHERE ts.VoucherID = @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, ts.timestamp AS SaleTimestamp FROM SaleVoucher ts INNER JOIN Vouchers b ON ts.VoucherID = b.VoucherID WHERE ts.BillID = @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));
}
+8 -9
View File
@@ -16,10 +16,9 @@ namespace Tanshu.Accounts.SqlDAO
public SalesBillItemBO GetDefaultSaleBillItem(Guid productID)
{
const string query = @"
SELECT p.ProductID, p.Name + ' (' + p.Units +')',
p.SalePrice, p.SaleTaxID, t.Rate AS TaxRate,
p.SaleLedgerID, l.CostCenterID
FROM Products p INNER JOIN Tax t ON p.SaleTaxID = t.TaxID INNER JOIN Ledgers l ON p.SaleLedgerID = l.LedgerID
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))
@@ -33,7 +32,8 @@ WHERE p.ProductID = @ProductID
productID = dr.GetGuid(0),
Name = dr.GetString(1),
Price = dr.GetDecimal(2),
Tax = dr.GetDecimal(4),
Vat = dr.GetDecimal(3),
ServiceTax = dr.GetDecimal(4),
Discount = 0,
location = "",
Printed = 0,
@@ -46,7 +46,7 @@ WHERE p.ProductID = @ProductID
public decimal GetProductDiscountLimit(Guid productID)
{
const string query = @"SELECT t.DiscountLimit FROM ProductTypes t INNER JOIN Products p ON t.ProductTypeID = p.ProductTypeID WHERE p.ProductID = @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))
@@ -157,12 +157,11 @@ WHERE p.ProductID = @ProductID
temp.VoucherID = voucherID.Value;
temp.InventoryID = Guid.NewGuid();
temp.Discount = item.Discount;
temp.IsRateFinal = true;
temp.ComplexProductID = null;
temp.ProductID = item.productID;
temp.Quantity = item.Quantity;
temp.Rate = item.Price;
temp.Tax = item.Tax;
temp.Vat = item.Vat;
temp.ServiceTax = item.ServiceTax;
localList.Add(item.productID, temp);
}
}
+62 -97
View File
@@ -26,7 +26,7 @@ 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 t.Type = 'S' AND s.PaidStatus != @Pending AND s.PaidStatus != @Void
WHERE s.PaidStatus != @Pending AND s.PaidStatus != @Void
AND t.Date BETWEEN @StartDate AND @FinishDate
GROUP BY i.Tax
ORDER BY Section DESC;";
@@ -45,7 +45,7 @@ ORDER BY Section DESC;";
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 t.Type = 's' AND s.PaidStatus != @Pending AND s.PaidStatus != @Void
WHERE s.PaidStatus != @Pending AND s.PaidStatus != @Void
AND t.Date BETWEEN @StartDate AND @FinishDate
AND i.Amount = 0";
cmd.CommandText = query;
@@ -61,8 +61,7 @@ AND i.Amount = 0";
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.Type = 's'
AND t.Date BETWEEN @StartDate AND @FinishDate
WHERE t.Date BETWEEN @StartDate AND @FinishDate
AND s.PaidStatus = @Void";
cmd.CommandText = query;
cmd.Parameters.AddWithValue("@Void", (int)PaidStatus.Void);
@@ -76,7 +75,7 @@ AND s.PaidStatus = @Void";
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.Type = 's' AND s.PaidStatus = @Pending
WHERE s.PaidStatus = @Pending
AND t.Date BETWEEN @StartDate AND @FinishDate";
cmd.CommandText = query;
cmd.Parameters.AddWithValue("@Pending", (int)PaidStatus.Pending);
@@ -90,7 +89,7 @@ AND t.Date BETWEEN @StartDate AND @FinishDate";
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 t.Type = 's' AND s.PaidStatus != @Pending AND s.PaidStatus != @Void
WHERE s.PaidStatus != @Pending AND s.PaidStatus != @Void
AND t.Date BETWEEN @StartDate AND @FinishDate";
cmd.CommandText = query;
cmd.Parameters.AddWithValue("@Pending", (int)PaidStatus.Pending);
@@ -105,7 +104,7 @@ AND t.Date BETWEEN @StartDate AND @FinishDate";
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.Type = 's' AND s.PaidStatus != @Pending AND s.PaidStatus != @Void
WHERE s.PaidStatus != @Pending AND s.PaidStatus != @Void
AND t.Date BETWEEN @StartDate AND @FinishDate";
cmd.CommandText = query;
cmd.Parameters.AddWithValue("@Pending", (int)PaidStatus.Pending);
@@ -116,7 +115,7 @@ AND t.Date BETWEEN @StartDate AND @FinishDate";
}
return list;
}
public void GetAdditionalInfo(ref decimal freeSale, ref decimal voids, ref decimal pending, ref decimal net, ref decimal tax, DateTime startDate, DateTime finishDate)
public decimal GetFreeSale(DateTime startDate, DateTime finishDate)
{
using (var cmd = new SqlCommand())
{
@@ -124,7 +123,7 @@ AND t.Date BETWEEN @StartDate AND @FinishDate";
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 t.Type = 's' AND s.PaidStatus != @Pending AND s.PaidStatus != @Void
WHERE s.PaidStatus != @Pending AND s.PaidStatus != @Void
AND t.LastEditDate BETWEEN @StartDate AND @FinishDate
AND i.Amount = 0";
cmd.CommandText = query;
@@ -132,70 +131,10 @@ AND i.Amount = 0";
cmd.Parameters.AddWithValue("@Void", (int)PaidStatus.Void);
cmd.Parameters.AddWithValue("@StartDate", startDate);
cmd.Parameters.AddWithValue("@FinishDate", finishDate);
freeSale = 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.Type = 's'
AND t.LastEditDate BETWEEN @StartDate AND @FinishDate
AND s.PaidStatus = @Void";
cmd.CommandText = query;
cmd.Parameters.AddWithValue("@Void", (int)PaidStatus.Void);
cmd.Parameters.AddWithValue("@StartDate", startDate);
cmd.Parameters.AddWithValue("@FinishDate", finishDate);
voids = 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.Type = 's' AND s.PaidStatus = @Pending
AND t.LastEditDate BETWEEN @StartDate AND @FinishDate
ORDER BY Amount DESC;";
cmd.CommandText = query;
cmd.Parameters.AddWithValue("@Pending", (int)PaidStatus.Pending);
cmd.Parameters.AddWithValue("@StartDate", startDate);
cmd.Parameters.AddWithValue("@FinishDate", finishDate);
pending = Math.Round((decimal)connection.ExecuteScalar(cmd));
}
using (var cmd = new SqlCommand())
{
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 t.Type = 's' AND s.PaidStatus != @Pending AND s.PaidStatus != @Void
AND t.LastEditDate BETWEEN @StartDate AND @FinishDate";
cmd.CommandText = query;
cmd.Parameters.AddWithValue("@Pending", (int)PaidStatus.Pending);
cmd.Parameters.AddWithValue("@Void", (int)PaidStatus.Void);
cmd.Parameters.AddWithValue("@StartDate", startDate);
cmd.Parameters.AddWithValue("@FinishDate", finishDate);
net = 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.Type = 's' AND s.PaidStatus != @Pending AND s.PaidStatus != @Void
AND t.LastEditDate BETWEEN @StartDate AND @FinishDate";
cmd.CommandText = query;
cmd.Parameters.AddWithValue("@Pending", (int)PaidStatus.Pending);
cmd.Parameters.AddWithValue("@Void", (int)PaidStatus.Void);
cmd.Parameters.AddWithValue("@StartDate", startDate);
cmd.Parameters.AddWithValue("@FinishDate", finishDate);
tax = Math.Round((decimal)connection.ExecuteScalar(cmd));
return Math.Round((decimal)connection.ExecuteScalar(cmd));
}
}
public List<SalesAnalysisDetailBO> GetSaleDetail(DateTime startDate, DateTime finishDate, Guid costCenterID)
public List<SalesAnalysisDetailBO> GetSaleDetail(DateTime startDate, DateTime finishDate, Guid productGroupID)
{
using (SqlCommand cmd = new SqlCommand())
{
@@ -204,10 +143,9 @@ SELECT p.Name AS Product, pt.Name AS Section, SUM(i.Quantity) AS Quantity, SUM(A
FROM Vouchers t INNER JOIN SaleVoucher s ON t.VoucherID = s.VoucherID
INNER JOIN Inventory i ON t.VoucherID = i.VoucherID
INNER JOIN Products p ON i.ProductID = p.ProductID
INNER JOIN ProductTypes pt ON p.ProductTypeID = pt.ProductTypeID
INNER JOIN Ledgers l ON p.SaleLedgerID = l.LedgerID
WHERE t.Type = 's' AND s.PaidStatus != @Pending AND s.PaidStatus != @Void
AND t.LastEditDate BETWEEN @StartDate AND @FinishDate AND l.CostCenterID = @CostCenterID
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
GROUP BY p.Name, pt.Name
ORDER BY Amount DESC;";
cmd.CommandText = query;
@@ -215,7 +153,7 @@ ORDER BY Amount DESC;";
cmd.Parameters.AddWithValue("@Void", (int)PaidStatus.Void);
cmd.Parameters.AddWithValue("@StartDate", startDate);
cmd.Parameters.AddWithValue("@FinishDate", finishDate);
cmd.Parameters.AddWithValue("@CostCenterID", costCenterID);
cmd.Parameters.AddWithValue("@ProductGroupID", productGroupID);
return BusinessObjectDAO<SalesAnalysisDetailBO>.GetBusinessObjects(connection.ExecuteReader(cmd));
}
@@ -225,15 +163,14 @@ ORDER BY Amount DESC;";
using (var cmd = new SqlCommand())
{
const string query = @"
SELECT c.CostCenterID AS TypeID, c.Name AS Section, SUM(i.Quantity) AS Quantity, SUM(Amount) AS Gross, SUM(i.Quantity * i.Rate * (1 - Discount)) AS Net
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
INNER JOIN Products p ON i.ProductID = p.ProductID
INNER JOIN Ledgers l ON p.SaleLedgerID = l.LedgerID
INNER JOIN CostCenters c ON l.CostCenterID = c.CostCenterID
WHERE t.Type = 's' AND s.PaidStatus != @Pending AND s.PaidStatus != @Void
INNER JOIN ProductGroups pg ON p.ProductGroupID = pg.ProductGroupID
WHERE s.PaidStatus != @Pending AND s.PaidStatus != @Void
AND t.LastEditDate BETWEEN @StartDate AND @FinishDate
GROUP BY c.CostCenterID, c.Name
GROUP BY pg.ProductGroupID, pg.Name
ORDER BY Net DESC;";
cmd.CommandText = query;
cmd.Parameters.AddWithValue("@Pending", (int)PaidStatus.Pending);
@@ -241,31 +178,28 @@ ORDER BY Net DESC;";
cmd.Parameters.AddWithValue("@StartDate", startDate);
cmd.Parameters.AddWithValue("@FinishDate", finishDate);
var list = BusinessObjectDAO<SalesAnalysisBO>.GetBusinessObjects(connection.ExecuteReader(cmd));
decimal gross = 0, net = 0;
decimal net = 0, vat = 0, serviceTax = 0;
foreach (var i in list)
{
gross += i.Gross;
net += i.Net;
vat += i.Vat;
serviceTax += i.ServiceTax;
}
list.Add(new SalesAnalysisBO
{
Section = "Total",
Gross = gross,
Net = net
});
list.Add(new SalesAnalysisBO() { Section = " -- ", Gross = 0, Net = 0 });
list.Add(new SalesAnalysisBO
{
Section = "Tax",
Net = gross - net
Name = "Total",
Net = net,
Vat = vat,
ServiceTax = serviceTax
});
list.Add(new SalesAnalysisBO() { Name = " -- " });
return GetSettlement(list, startDate, finishDate);
}
}
private List<SalesAnalysisBO> GetSettlement(List<SalesAnalysisBO> outList, DateTime startDate, DateTime finishDate)
{
outList.Add(new SalesAnalysisBO() { Section = " -- ", Gross = 0, Net = 0 });
outList.Add(new SalesAnalysisBO() { Name = " -- " });
if (finishDate <= startDate)
return new List<SalesAnalysisBO>();
using (var cmd = new SqlCommand())
@@ -287,9 +221,41 @@ ORDER BY s.PaidStatus
foreach (var item in list)
{
amount += item.Amount;
outList.Add(new SalesAnalysisBO(){ Section = item.Status.ToString() , Net = item.Amount});
outList.Add(new SalesAnalysisBO() { Name = item.Status.ToString(), Net = item.Amount });
}
outList.Add(new SalesAnalysisBO() { Section = "Total", Net = amount });
outList.Add(new SalesAnalysisBO() { Name = "Total", Net = amount });
return GetAdvances(outList, startDate, finishDate);
}
}
private List<SalesAnalysisBO> GetAdvances(List<SalesAnalysisBO> outList, DateTime startDate, DateTime finishDate)
{
outList.Add(new SalesAnalysisBO() { Name = " -- " });
if (finishDate <= startDate)
return new List<SalesAnalysisBO>();
using (var cmd = new SqlCommand())
{
string query = "SELECT a.*, ui.Name AS Cashier, ISNULL(uo.Name, '') AS UserOut FROM Advances a INNER JOIN Users ui ON a.CashierIn = ui.UserID LEFT OUTER JOIN Users uo ON a.CashierOut = uo.UserID WHERE DateIn BETWEEN @StartDate AND @FinishDate OR (DateOut is not null AND DateOut BETWEEN @StartDate AND @FinishDate)";
cmd.CommandText = query;
cmd.Parameters.AddWithValue("@StartDate", startDate);
cmd.Parameters.AddWithValue("@FinishDate", finishDate);
var list = BusinessObjectDAO<AdvanceDisplayBO>.GetBusinessObjects(connection.ExecuteReader(cmd));
decimal amount = 0;
foreach (var item in list)
{
if (item.DateIn >= startDate && item.DateIn <= finishDate)
{
amount += item.Amount;
outList.Add(new SalesAnalysisBO() { Name = string.Format("Advance In {0}", item.Cashier), Net = item.Amount });
}
if (item.DateOut.HasValue && item.DateOut >= startDate && item.DateOut <= finishDate)
{
amount -= item.Amount;
outList.Add(new SalesAnalysisBO() { Name = string.Format("Advance Out {0}", item.UserOut), Net = item.Amount });
}
}
outList.Add(new SalesAnalysisBO() { Name = "Total Advance Taken", Net = amount });
return outList;
}
}
@@ -299,8 +265,7 @@ ORDER BY s.PaidStatus
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.Type = 'S'
AND t.LastEditDate BETWEEN @StartDate AND @FinishDate
WHERE t.LastEditDate BETWEEN @StartDate AND @FinishDate
AND s.PaidStatus = @PaidStatus
";
using (var cmd = new SqlCommand(query))
@@ -67,7 +67,6 @@
<Compile Include="ManagementDAO.cs" />
<Compile Include="WaiterDAO.cs" />
<Compile Include="InventoryDAO.cs" />
<Compile Include="LedgerDAO.cs" />
<Compile Include="MembershipDAO.cs" />
<Compile Include="PaymentDAO.cs" />
<Compile Include="ProductDAO.cs" />
-8
View File
@@ -46,7 +46,6 @@ namespace Tanshu.Accounts.SqlDAO
SELECT @UserID = NEWID()
INSERT INTO Users (UserID, Name, Password, LockedOut)
VALUES (@UserID, @Name, @Password, @LockedOut)
SELECT @timestamp = timestamp FROM Users WHERE UserID = @UserID
"))
{
cmd.Parameters.Add("@UserID", System.Data.SqlDbType.UniqueIdentifier);
@@ -54,11 +53,8 @@ SELECT @timestamp = timestamp FROM Users WHERE UserID = @UserID
cmd.Parameters.AddWithValue("@Name", user.Name);
cmd.Parameters.AddWithValue("@Password", user.Password);
cmd.Parameters.AddWithValue("@LockedOut", user.LockedOut);
cmd.Parameters.Add("@timestamp", System.Data.SqlDbType.Timestamp);
cmd.Parameters["@timestamp"].Direction = System.Data.ParameterDirection.Output;
connection.ExecuteNonQuery(cmd);
user.UserID = (Guid)cmd.Parameters["@UserID"].Value;
user.timestamp = (byte[])cmd.Parameters["@timestamp"].Value;
return true;
}
}
@@ -90,17 +86,13 @@ UPDATE Users SET
Password = @Password,
LockedOut = @LockedOut
WHERE UserID = @UserID;
SELECT @timestamp = timestamp FROM Users WHERE UserID = @UserID
"))
{
cmd.Parameters.AddWithValue("@UserID", user.UserID);
cmd.Parameters.AddWithValue("@Name", user.Name);
cmd.Parameters.AddWithValue("@Password", user.Password);
cmd.Parameters.AddWithValue("@LockedOut", user.LockedOut);
cmd.Parameters.Add("@timestamp", System.Data.SqlDbType.Timestamp);
cmd.Parameters["@timestamp"].Direction = System.Data.ParameterDirection.Output;
connection.ExecuteNonQuery(cmd);
user.timestamp = (byte[])cmd.Parameters["@timestamp"].Value;
return true;
}
}
+7 -21
View File
@@ -15,24 +15,21 @@ namespace Tanshu.Accounts.SqlDAO
public bool Insert(VoucherBO voucher)
{
using (SqlCommand cmd = new SqlCommand(@"
SELECT @Code = ISNULL(MAX(Code), 0) + 1 FROM Vouchers WHERE Type = @Type
SELECT @Code = ISNULL(MAX(Code), 0) + 1 FROM Vouchers;
SELECT @VoucherID = NEWID(),
@CreationDate = GETDATE(),
@LastEditDate = GETDATE(),
@Date = COALESCE(@Date, GETDATE())
@Date = COALESCE(@Date, GETDATE());
INSERT INTO [Vouchers] ([VoucherID], [Code], [Ref], [Date], [Narration], [UserID], [CreationDate], [LastEditDate], [Type])
VALUES (@VoucherID, @Code, @Ref, @Date, @Narration, @UserID, @CreationDate, @LastEditDate, @Type)
SELECT @timestamp = timestamp FROM [dbo].[Vouchers] WHERE VoucherID = @VoucherID
INSERT INTO [Vouchers] ([VoucherID], [Code], [Date], [Narration], [UserID], [CreationDate], [LastEditDate])
VALUES (@VoucherID, @Code, @Date, @Narration, @UserID, @CreationDate, @LastEditDate);
"))
{
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.AddWithValue("@Ref", voucher.Ref);
cmd.Parameters.Add("@Date", System.Data.SqlDbType.DateTime);
if (voucher.Date.HasValue)
@@ -47,17 +44,12 @@ namespace Tanshu.Accounts.SqlDAO
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("@Type", voucher.Type);
cmd.Parameters.Add("@timestamp", System.Data.SqlDbType.Timestamp);
cmd.Parameters["@timestamp"].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.timestamp = (byte[])cmd.Parameters["@timestamp"].Value;
return true;
}
}
@@ -83,15 +75,13 @@ namespace Tanshu.Accounts.SqlDAO
@Date = COALESCE(@Date, GETDATE())
UPDATE [Vouchers]
SET [Ref] = @Ref,
[Date] = @Date,
SET [Date] = @Date,
[Narration] = @Narration,
[UserID] = @UserID,
[LastEditDate] = @LastEditDate,
[Type] = @Type
[LastEditDate] = @LastEditDate
WHERE [VoucherID] = @VoucherID
SELECT @Code = Code, @CreationDate = CreationDate, @timestamp = timestamp
SELECT @Code = Code, @CreationDate = CreationDate
FROM [Vouchers]
WHERE [VoucherID] = @VoucherID
"))
@@ -99,7 +89,6 @@ namespace Tanshu.Accounts.SqlDAO
cmd.Parameters.AddWithValue("@VoucherID", voucher.VoucherID);
cmd.Parameters.AddWithValue("@Code", voucher.Code);
cmd.Parameters["@Code"].Direction = System.Data.ParameterDirection.Output;
cmd.Parameters.AddWithValue("@Ref", voucher.Ref);
cmd.Parameters.Add("@Date", System.Data.SqlDbType.DateTime);
if (voucher.Date.HasValue)
@@ -114,14 +103,11 @@ namespace Tanshu.Accounts.SqlDAO
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("@Type", voucher.Type);
cmd.Parameters.AddWithValue("@timestamp", voucher.timestamp);
connection.ExecuteNonQuery(cmd);
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.timestamp = (byte[])cmd.Parameters["@timestamp"].Value;
return true;
}
}
-8
View File
@@ -18,7 +18,6 @@ namespace Tanshu.Accounts.SqlDAO
using (SqlCommand cmd = new SqlCommand(@"
SELECT @WaiterID = NEWID(), @Code = ISNULL(MAX(Code), 0) + 1 FROM Waiters;
INSERT INTO Waiters (WaiterID, Code, Name) VALUES (@WaiterID, @Code, @Name);
SELECT @timestamp = timestamp FROM Waiters WHERE WaiterID = @WaiterID;
"))
{
cmd.Parameters.Add("@WaiterID", System.Data.SqlDbType.UniqueIdentifier);
@@ -26,12 +25,9 @@ SELECT @timestamp = timestamp FROM Waiters WHERE WaiterID = @WaiterID;
cmd.Parameters.Add("@Code", System.Data.SqlDbType.Int);
cmd.Parameters["@Code"].Direction = System.Data.ParameterDirection.Output;
cmd.Parameters.AddWithValue("@Name", waiter.Name);
cmd.Parameters.Add("@timestamp", System.Data.SqlDbType.Timestamp);
cmd.Parameters["@timestamp"].Direction = System.Data.ParameterDirection.Output;
connection.ExecuteNonQuery(cmd);
waiter.WaiterID = (Guid)cmd.Parameters["@WaiterID"].Value;
waiter.Code = (int)cmd.Parameters["@Code"].Value;
waiter.timestamp = (byte[])cmd.Parameters["@timestamp"].Value;
return true;
}
}
@@ -39,16 +35,12 @@ SELECT @timestamp = timestamp FROM Waiters WHERE WaiterID = @WaiterID;
{
using (SqlCommand cmd = new SqlCommand(@"
UPDATE Waiters SET Name = @Name, Code = @Code WHERE WaiterID = @WaiterID;
SELECT @timestamp = timestamp FROM Waiters WHERE WaiterID = @WaiterID;
"))
{
cmd.Parameters.AddWithValue("@WaiterID", waiter.WaiterID);
cmd.Parameters.AddWithValue("@Code", waiter.Code);
cmd.Parameters.AddWithValue("@Name", waiter.Name);
cmd.Parameters.Add("@timestamp", System.Data.SqlDbType.Timestamp);
cmd.Parameters["@timestamp"].Direction = System.Data.ParameterDirection.Output;
connection.ExecuteNonQuery(cmd);
waiter.timestamp = (byte[])cmd.Parameters["@timestamp"].Value;
return true;
}
}