├── SimpleBilling ├── Iconsmind-Outline-Billing.ico ├── Properties │ ├── licenses.licx │ ├── Settings.settings │ ├── Settings.Designer.cs │ ├── AssemblyInfo.cs │ ├── Resources.Designer.cs │ ├── app.manifest │ └── Resources.resx ├── Resources │ ├── Iconsmind-Outline-Billing.ico │ └── one-click-demo-import.2.5.2.zip ├── Model │ ├── BillingDBInitializer.cs │ ├── Bank.cs │ ├── BaseEntity.cs │ ├── SMSLog.cs │ ├── PendingJob.cs │ ├── Category.cs │ ├── UserTypeConfigurations.cs │ ├── MileageTracking.cs │ ├── Shelf.cs │ ├── Users.cs │ ├── Cheque.cs │ ├── Customers.cs │ ├── PurchaseOrder.cs │ ├── Setting.cs │ ├── OrderedItem.cs │ ├── BusinessModel.cs │ ├── Employee.cs │ ├── Supplier.cs │ ├── Vehicle.cs │ ├── ReceiptBody.cs │ ├── GRNDetails.cs │ ├── Item.cs │ ├── GRNHeader.cs │ ├── ReceiptHeader.cs │ └── BillingContext.cs ├── Migrations │ ├── Configuration.cs │ ├── 202004221641345_billing3.cs │ ├── 202004221659462_billing4.cs │ ├── 202004221836553_billing5.cs │ ├── 202004221641345_billing3.Designer.cs │ ├── 202004221659462_billing4.Designer.cs │ ├── 202004221836553_billing5.Designer.cs │ ├── 202004221836553_billing5.resx │ ├── 202004221641345_billing3.resx │ └── 202004221659462_billing4.resx ├── SMS │ ├── Rand.cs │ └── Sender.cs ├── Program.cs ├── packages.config ├── Reports │ ├── VoidedReceipts.cs │ └── VoidedReceipts.Designer.cs ├── App.config ├── MasterForms │ ├── CustomerLookUp.cs │ ├── ItemLookup.cs │ ├── ManageStock.cs │ ├── ManageShelves.cs │ ├── ManageBanks.resx │ ├── Settings.resx │ ├── ManageCategory.cs │ ├── ManageCheques.cs │ ├── GRNInvoices.cs │ ├── ManageBanks.cs │ ├── CustomerLookUp.Designer.cs │ ├── ItemLookup.Designer.cs │ ├── ManageEmployees.cs │ ├── LoadReceipt.cs │ ├── ManageCustomers.cs │ └── BusinessInfo.cs ├── ExportJSON.cs ├── ExportJson.cs ├── Login.cs └── Login.resx ├── SimpleBillingconString.json ├── SimpleBilling.sln ├── .gitattributes └── .gitignore /SimpleBilling/Iconsmind-Outline-Billing.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nirzaf/simple-billing/HEAD/SimpleBilling/Iconsmind-Outline-Billing.ico -------------------------------------------------------------------------------- /SimpleBilling/Properties/licenses.licx: -------------------------------------------------------------------------------- 1 | Spire.DataExport.PDF.PDFExport, Spire.DataExport, Version=3.5.10.2040, Culture=neutral, PublicKeyToken=663f351905198cb3 2 | -------------------------------------------------------------------------------- /SimpleBilling/Resources/Iconsmind-Outline-Billing.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nirzaf/simple-billing/HEAD/SimpleBilling/Resources/Iconsmind-Outline-Billing.ico -------------------------------------------------------------------------------- /SimpleBilling/Resources/one-click-demo-import.2.5.2.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nirzaf/simple-billing/HEAD/SimpleBilling/Resources/one-click-demo-import.2.5.2.zip -------------------------------------------------------------------------------- /SimpleBillingconString.json: -------------------------------------------------------------------------------- 1 | { 2 | "Connection": "Data Source = VL2\\SQLEXPRESS; Initial Catalog = Billing; Integrated Security = True; MultipleActiveResultSets = True" 3 | } -------------------------------------------------------------------------------- /SimpleBilling/Model/BillingDBInitializer.cs: -------------------------------------------------------------------------------- 1 | using System.Data.Entity; 2 | 3 | namespace SimpleBilling.Model 4 | { 5 | public class BillingDBInitializer : CreateDatabaseIfNotExists 6 | { 7 | } 8 | } -------------------------------------------------------------------------------- /SimpleBilling/Properties/Settings.settings: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /SimpleBilling/Model/Bank.cs: -------------------------------------------------------------------------------- 1 | using System.ComponentModel.DataAnnotations; 2 | 3 | namespace SimpleBilling.Model 4 | { 5 | public class Bank : BaseEntity 6 | { 7 | [Key] 8 | public int BankId { get; set; } 9 | 10 | [MaxLength(100)] 11 | public string BankName { get; set; } 12 | } 13 | } -------------------------------------------------------------------------------- /SimpleBilling/Migrations/Configuration.cs: -------------------------------------------------------------------------------- 1 | namespace SimpleBilling.Migrations 2 | { 3 | using System.Data.Entity.Migrations; 4 | 5 | internal sealed class Configuration : DbMigrationsConfiguration 6 | { 7 | public Configuration() 8 | { 9 | AutomaticMigrationsEnabled = true; 10 | } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /SimpleBilling/Model/BaseEntity.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.ComponentModel; 3 | 4 | namespace SimpleBilling.Model 5 | { 6 | public class BaseEntity 7 | { 8 | public DateTime? CreatedDate { get; set; } 9 | public DateTime? UpdatedDate { get; set; } 10 | [DefaultValue(false)] 11 | public bool IsDeleted { get; set; } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /SimpleBilling/Model/SMSLog.cs: -------------------------------------------------------------------------------- 1 | using System.ComponentModel.DataAnnotations; 2 | 3 | namespace SimpleBilling.Model 4 | { 5 | public class SMSLog : BaseEntity 6 | { 7 | [Key] 8 | public string LogKey { get; set; } 9 | public string LogMessage { get; set; } 10 | public string Number { get; set; } 11 | public string Log { get; set; } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /SimpleBilling/Migrations/202004221641345_billing3.cs: -------------------------------------------------------------------------------- 1 | namespace SimpleBilling.Migrations 2 | { 3 | using System; 4 | using System.Data.Entity.Migrations; 5 | 6 | public partial class billing3 : DbMigration 7 | { 8 | public override void Up() 9 | { 10 | } 11 | 12 | public override void Down() 13 | { 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /SimpleBilling/Migrations/202004221659462_billing4.cs: -------------------------------------------------------------------------------- 1 | namespace SimpleBilling.Migrations 2 | { 3 | using System; 4 | using System.Data.Entity.Migrations; 5 | 6 | public partial class billing4 : DbMigration 7 | { 8 | public override void Up() 9 | { 10 | } 11 | 12 | public override void Down() 13 | { 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /SimpleBilling/Migrations/202004221836553_billing5.cs: -------------------------------------------------------------------------------- 1 | namespace SimpleBilling.Migrations 2 | { 3 | using System; 4 | using System.Data.Entity.Migrations; 5 | 6 | public partial class billing5 : DbMigration 7 | { 8 | public override void Up() 9 | { 10 | } 11 | 12 | public override void Down() 13 | { 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /SimpleBilling/Model/PendingJob.cs: -------------------------------------------------------------------------------- 1 | using System.ComponentModel.DataAnnotations; 2 | 3 | namespace SimpleBilling.Model 4 | { 5 | public class PendingJob : BaseEntity 6 | { 7 | [Key] 8 | public string ReceiptNo { get; set; } 9 | [MaxLength(30)] 10 | public string VehicleNumber { get; set; } 11 | [MaxLength(30)] 12 | public string Date { get; set; } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /SimpleBilling/Model/Category.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.ComponentModel.DataAnnotations; 3 | 4 | namespace SimpleBilling.Model 5 | { 6 | public class Category : BaseEntity 7 | { 8 | [Key] 9 | public int CategoryId { get; set; } 10 | [MaxLength(150)] 11 | public string CategoryName { get; set; } 12 | public virtual ICollection Items { get; set; } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /SimpleBilling/Model/UserTypeConfigurations.cs: -------------------------------------------------------------------------------- 1 | using System.Data.Entity.ModelConfiguration; 2 | 3 | namespace SimpleBilling.Model 4 | { 5 | public class UserTypeConfigurations : EntityTypeConfiguration 6 | { 7 | public UserTypeConfigurations() 8 | { 9 | Property(s => s.Username).IsRequired().HasMaxLength(50); 10 | 11 | Property(s => s.Username).IsConcurrencyToken(); 12 | } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /SimpleBilling/Model/MileageTracking.cs: -------------------------------------------------------------------------------- 1 | using System.ComponentModel.DataAnnotations; 2 | 3 | namespace SimpleBilling.Model 4 | { 5 | public class MileageTracking : BaseEntity 6 | { 7 | [Key] 8 | public int MileageId { get; set; } 9 | 10 | public int Mileage { get; set; } 11 | public int NextServiceDue { get; set; } 12 | public string VehicleNo { get; set; } 13 | public string ReceiptNo { get; set; } 14 | } 15 | } -------------------------------------------------------------------------------- /SimpleBilling/Model/Shelf.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.ComponentModel; 3 | using System.ComponentModel.DataAnnotations; 4 | 5 | namespace SimpleBilling.Model 6 | { 7 | public class Shelf : BaseEntity 8 | { 9 | [Key] 10 | public int ShelfId { get; set; } 11 | [Required] 12 | [MaxLength(150)] 13 | public string ShelfName { get; set; } 14 | public virtual ICollection Items { get; set; } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /SimpleBilling/Model/Users.cs: -------------------------------------------------------------------------------- 1 | using System.ComponentModel.DataAnnotations; 2 | 3 | namespace SimpleBilling.Model 4 | { 5 | public class Users : BaseEntity 6 | { 7 | [Key] 8 | public int UserId { get; set; } 9 | [MaxLength(50)] 10 | public string Username { get; set; } 11 | [MaxLength(50)] 12 | public string Password { get; set; } 13 | public int UserType { get; set; } 14 | public int EmployeeId { get; set; } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /SimpleBilling/SMS/Rand.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq; 3 | 4 | namespace SimpleBilling.SMS 5 | { 6 | public static class Rand 7 | { 8 | private static Random Random = new Random(); 9 | public static string RandomString(int length) 10 | { 11 | const string chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; 12 | return new string(Enumerable.Repeat(chars, length) 13 | .Select(s => s[Random.Next(s.Length)]).ToArray()); 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /SimpleBilling/Model/Cheque.cs: -------------------------------------------------------------------------------- 1 | using System.ComponentModel.DataAnnotations; 2 | 3 | namespace SimpleBilling.Model 4 | { 5 | public class Cheque : BaseEntity 6 | { 7 | [Key] 8 | public string ChequeNo { get; set; } 9 | 10 | [MaxLength(150)] 11 | public string PayeeName { get; set; } 12 | 13 | [MaxLength(30)] 14 | public string DueDate { get; set; } 15 | 16 | public float Amount { get; set; } 17 | public string PaidBy { get; set; } 18 | public int Bank { get; set; } 19 | } 20 | } -------------------------------------------------------------------------------- /SimpleBilling/Model/Customers.cs: -------------------------------------------------------------------------------- 1 | using System.ComponentModel.DataAnnotations; 2 | 3 | namespace SimpleBilling.Model 4 | { 5 | public class Customers : BaseEntity 6 | { 7 | [Key] 8 | public int CustomerId { get; set; } 9 | [MaxLength(100)] 10 | public string Name { get; set; } 11 | [MaxLength(25)] 12 | public string Contact { get; set; } 13 | [MaxLength(100)] 14 | public string Email { get; set; } 15 | [MaxLength(250)] 16 | public string Address { get; set; } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /SimpleBilling/Program.cs: -------------------------------------------------------------------------------- 1 | using SimpleBilling.MasterForms; 2 | using System; 3 | using System.Windows.Forms; 4 | 5 | namespace SimpleBilling 6 | { 7 | public static class Program 8 | { 9 | /// 10 | /// The main entry point for the application. 11 | /// 12 | [STAThread] 13 | private static void Main() 14 | { 15 | Application.EnableVisualStyles(); 16 | Application.SetCompatibleTextRenderingDefault(false); 17 | Application.Run(new Login()); 18 | } 19 | } 20 | } -------------------------------------------------------------------------------- /SimpleBilling/Model/PurchaseOrder.cs: -------------------------------------------------------------------------------- 1 | using System.ComponentModel; 2 | using System.ComponentModel.DataAnnotations; 3 | 4 | namespace SimpleBilling.Model 5 | { 6 | public class PurchaseOrder : BaseEntity 7 | { 8 | [Key] 9 | public string OrderUniqueId { get; set; } 10 | public string OrderedDate { get; set; } 11 | public int SupplierId { get; set; } 12 | [DefaultValue(false)] 13 | public bool IsOrderCompleted { get; set; } 14 | [DefaultValue(false)] 15 | public bool IsReceived { get; set; } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /SimpleBilling/Model/Setting.cs: -------------------------------------------------------------------------------- 1 | using System.ComponentModel; 2 | using System.ComponentModel.DataAnnotations; 3 | 4 | namespace SimpleBilling.Model 5 | { 6 | public class Setting : BaseEntity 7 | { 8 | [Key] 9 | public int SettingsId { get; set; } 10 | public int UserId { get; set; } 11 | public string DefaultPath { get; set; } 12 | public string GRNPath { get; set; } 13 | public string ExceptionPath { get; set; } 14 | public int SetMinValue { get; set; } 15 | public string QuotationPath { get; set; } 16 | [DefaultValue(false)] 17 | public bool EnableSMS { get; set; } 18 | } 19 | } -------------------------------------------------------------------------------- /SimpleBilling/Model/OrderedItem.cs: -------------------------------------------------------------------------------- 1 | using System.ComponentModel; 2 | using System.ComponentModel.DataAnnotations; 3 | using System.ComponentModel.DataAnnotations.Schema; 4 | 5 | namespace SimpleBilling.Model 6 | { 7 | public class OrderedItem : BaseEntity 8 | { 9 | [Key] 10 | [Column(Order = 1)] 11 | public string ItemCode { get; set; } 12 | [Key] 13 | [Column(Order = 2)] 14 | public string OrderId { get; set; } 15 | public int Quantity { get; set; } 16 | [MaxLength(30)] 17 | public string UnitType { get; set; } 18 | [DefaultValue(false)] 19 | public bool IsReceived { get; set; } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /SimpleBilling/Model/BusinessModel.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel; 4 | using System.ComponentModel.DataAnnotations; 5 | using System.Linq; 6 | using System.Text; 7 | using System.Threading.Tasks; 8 | 9 | namespace SimpleBilling.Model 10 | { 11 | public class BusinessModel : BaseEntity 12 | { 13 | [Key] 14 | public int Id { get; set; } 15 | [MaxLength(100)] 16 | public string Name { get; set; } 17 | [MaxLength(200)] 18 | public string Address { get; set; } 19 | [MaxLength(20)] 20 | public string Contact { get; set; } 21 | [DefaultValue(false)] 22 | public bool IsActive { get; set; } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /SimpleBilling/Model/Employee.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel.DataAnnotations; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | 8 | namespace SimpleBilling.Model 9 | { 10 | public class Employee : BaseEntity 11 | { 12 | [Key] 13 | public int EmployeeId { get; set; } 14 | [MaxLength(150)] 15 | public string EmployeeName { get; set; } 16 | [MaxLength(25)] 17 | public string Contact { get; set; } 18 | [MaxLength(250)] 19 | public string Address { get; set; } 20 | [EmailAddress] 21 | public string Email { get; set; } 22 | public int Status { get; set; } 23 | [MaxLength(10)] 24 | public string SecretCode { get; set; } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /SimpleBilling/Model/Supplier.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.ComponentModel.DataAnnotations; 3 | using System.ComponentModel.DataAnnotations.Schema; 4 | 5 | namespace SimpleBilling.Model 6 | { 7 | public class Supplier : BaseEntity 8 | { 9 | [Key] 10 | public int SupplierId { get; set; } 11 | [MaxLength(150)] 12 | [Required] 13 | [Index(IsUnique = true)] 14 | public string Name { get; set; } 15 | [MaxLength(25)] 16 | [Required] 17 | public string Contact { get; set; } 18 | public string Address { get; set; } 19 | [EmailAddress] 20 | public string Email { get; set; } 21 | public float PendingAmount { get; set; } 22 | public virtual ICollection GRNHeaders { get; set; } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /SimpleBilling/Model/Vehicle.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel; 4 | using System.ComponentModel.DataAnnotations; 5 | 6 | namespace SimpleBilling.Model 7 | { 8 | public class Vehicle : BaseEntity 9 | { 10 | [Key] 11 | public string VehicleNo { get; set; } 12 | 13 | [MaxLength(100)] 14 | public string Brand { get; set; } 15 | 16 | [MaxLength(100)] 17 | public string Model { get; set; } 18 | 19 | public string Type { get; set; } 20 | 21 | [DefaultValue(0)] 22 | public int CurrentMileage { get; set; } 23 | 24 | [DefaultValue(0)] 25 | public int ServiceMileageDue { get; set; } 26 | 27 | public int OwnerId { get; set; } 28 | public DateTime AddedDate { get; set; } 29 | } 30 | } -------------------------------------------------------------------------------- /SimpleBilling/Model/ReceiptBody.cs: -------------------------------------------------------------------------------- 1 | using System.ComponentModel; 2 | using System.ComponentModel.DataAnnotations; 3 | using System.ComponentModel.DataAnnotations.Schema; 4 | 5 | namespace SimpleBilling.Model 6 | { 7 | public class ReceiptBody : BaseEntity 8 | { 9 | [Key] 10 | [Column(Order = 1)] 11 | public string ReceiptNo { get; set; } 12 | 13 | [Key] 14 | [Column(Order = 2)] 15 | public int ProductId { get; set; } 16 | 17 | [Required] 18 | public float UnitPrice { get; set; } 19 | 20 | [Required] 21 | public int Quantity { get; set; } 22 | 23 | [DefaultValue(0)] 24 | public float Discount { get; set; } 25 | 26 | public float SubTotal { get; set; } 27 | 28 | [Required] 29 | public float NetTotal { get; set; } 30 | 31 | [DefaultValue(false)] 32 | public bool IsReturned { get; set; } 33 | } 34 | } -------------------------------------------------------------------------------- /SimpleBilling/Migrations/202004221641345_billing3.Designer.cs: -------------------------------------------------------------------------------- 1 | // 2 | namespace SimpleBilling.Migrations 3 | { 4 | using System.CodeDom.Compiler; 5 | using System.Data.Entity.Migrations; 6 | using System.Data.Entity.Migrations.Infrastructure; 7 | using System.Resources; 8 | 9 | [GeneratedCode("EntityFramework.Migrations", "6.4.0")] 10 | public sealed partial class billing3 : IMigrationMetadata 11 | { 12 | private readonly ResourceManager Resources = new ResourceManager(typeof(billing3)); 13 | 14 | string IMigrationMetadata.Id 15 | { 16 | get { return "202004221641345_billing3"; } 17 | } 18 | 19 | string IMigrationMetadata.Source 20 | { 21 | get { return null; } 22 | } 23 | 24 | string IMigrationMetadata.Target 25 | { 26 | get { return Resources.GetString("Target"); } 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /SimpleBilling/Migrations/202004221659462_billing4.Designer.cs: -------------------------------------------------------------------------------- 1 | // 2 | namespace SimpleBilling.Migrations 3 | { 4 | using System.CodeDom.Compiler; 5 | using System.Data.Entity.Migrations; 6 | using System.Data.Entity.Migrations.Infrastructure; 7 | using System.Resources; 8 | 9 | [GeneratedCode("EntityFramework.Migrations", "6.4.0")] 10 | public sealed partial class billing4 : IMigrationMetadata 11 | { 12 | private readonly ResourceManager Resources = new ResourceManager(typeof(billing4)); 13 | 14 | string IMigrationMetadata.Id 15 | { 16 | get { return "202004221659462_billing4"; } 17 | } 18 | 19 | string IMigrationMetadata.Source 20 | { 21 | get { return null; } 22 | } 23 | 24 | string IMigrationMetadata.Target 25 | { 26 | get { return Resources.GetString("Target"); } 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /SimpleBilling/Migrations/202004221836553_billing5.Designer.cs: -------------------------------------------------------------------------------- 1 | // 2 | namespace SimpleBilling.Migrations 3 | { 4 | using System.CodeDom.Compiler; 5 | using System.Data.Entity.Migrations; 6 | using System.Data.Entity.Migrations.Infrastructure; 7 | using System.Resources; 8 | 9 | [GeneratedCode("EntityFramework.Migrations", "6.4.0")] 10 | public sealed partial class billing5 : IMigrationMetadata 11 | { 12 | private readonly ResourceManager Resources = new ResourceManager(typeof(billing5)); 13 | 14 | string IMigrationMetadata.Id 15 | { 16 | get { return "202004221836553_billing5"; } 17 | } 18 | 19 | string IMigrationMetadata.Source 20 | { 21 | get { return null; } 22 | } 23 | 24 | string IMigrationMetadata.Target 25 | { 26 | get { return Resources.GetString("Target"); } 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /SimpleBilling/Model/GRNDetails.cs: -------------------------------------------------------------------------------- 1 | using System.ComponentModel; 2 | using System.ComponentModel.DataAnnotations; 3 | using System.ComponentModel.DataAnnotations.Schema; 4 | 5 | namespace SimpleBilling.Model 6 | { 7 | public class GrnDetails : BaseEntity 8 | { 9 | [Key] 10 | [Column(Order = 1)] 11 | public int GRN_Id { get; set; } 12 | 13 | [Key] 14 | [Column(Order = 2)] 15 | public string GRNCode { get; set; } 16 | [Key] 17 | [Column(Order = 3)] 18 | public int ProductId { get; set; } 19 | 20 | [DefaultValue(false)] 21 | public bool IsReturned { get; set; } 22 | 23 | [Required] 24 | public float UnitCost { get; set; } 25 | 26 | [Required] 27 | public int Quantity { get; set; } 28 | 29 | [DefaultValue(0)] 30 | public float Discount { get; set; } 31 | 32 | [Required] 33 | public float SubTotal { get; set; } 34 | 35 | public float GrossTotal { get; set; } 36 | } 37 | } -------------------------------------------------------------------------------- /SimpleBilling/Model/Item.cs: -------------------------------------------------------------------------------- 1 | using System.ComponentModel; 2 | using System.ComponentModel.DataAnnotations; 3 | 4 | namespace SimpleBilling.Model 5 | { 6 | public class Item : BaseEntity 7 | { 8 | [Key] 9 | public int Id { get; set; } 10 | 11 | [MaxLength(50)] 12 | public string Code { get; set; } 13 | 14 | [MaxLength(250)] 15 | public string ItemName { get; set; } 16 | 17 | public string PrintableName { get; set; } 18 | 19 | [MaxLength(25)] 20 | public string Unit { get; set; } 21 | 22 | public float UnitCost { get; set; } 23 | 24 | [MaxLength(250)] 25 | public string Barcode { get; set; } 26 | 27 | [DefaultValue(0)] 28 | public int StockQty { get; set; } 29 | 30 | public float SellingPrice { get; set; } 31 | 32 | [DefaultValue(false)] 33 | public bool IsService { get; set; } 34 | 35 | public virtual Category Categories { get; set; } 36 | public virtual Shelf Shelfs { get; set; } 37 | } 38 | } -------------------------------------------------------------------------------- /SimpleBilling/Properties/Settings.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.42000 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace SimpleBilling.Properties { 12 | 13 | 14 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 15 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "17.0.3.0")] 16 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { 17 | 18 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); 19 | 20 | public static Settings Default { 21 | get { 22 | return defaultInstance; 23 | } 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /SimpleBilling.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 16 4 | VisualStudioVersion = 16.0.30011.22 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SimpleBilling", "SimpleBilling\SimpleBilling.csproj", "{06C94AC4-46C2-416A-9BEE-7FA2CE77E708}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Any CPU = Debug|Any CPU 11 | Release|Any CPU = Release|Any CPU 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {06C94AC4-46C2-416A-9BEE-7FA2CE77E708}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 15 | {06C94AC4-46C2-416A-9BEE-7FA2CE77E708}.Debug|Any CPU.Build.0 = Debug|Any CPU 16 | {06C94AC4-46C2-416A-9BEE-7FA2CE77E708}.Release|Any CPU.ActiveCfg = Release|Any CPU 17 | {06C94AC4-46C2-416A-9BEE-7FA2CE77E708}.Release|Any CPU.Build.0 = Release|Any CPU 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | GlobalSection(ExtensibilityGlobals) = postSolution 23 | SolutionGuid = {48860D14-145D-4A79-A179-F59DB2D1DE10} 24 | EndGlobalSection 25 | EndGlobal 26 | -------------------------------------------------------------------------------- /SimpleBilling/packages.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /SimpleBilling/Model/GRNHeader.cs: -------------------------------------------------------------------------------- 1 | using System.ComponentModel; 2 | using System.ComponentModel.DataAnnotations; 3 | 4 | namespace SimpleBilling.Model 5 | { 6 | public class GrnHeader : BaseEntity 7 | { 8 | [Key] 9 | public int GRN_Id { get; set; } 10 | 11 | public string GRN_No { get; set; } 12 | public string GRN_Date { get; set; } 13 | public string Time { get; set; } 14 | public string ReferenceNo { get; set; } 15 | 16 | [MaxLength(10)] 17 | public string PaymentType { get; set; } 18 | 19 | [DefaultValue(false)] 20 | public bool IsPaid { get; set; } 21 | 22 | public virtual Supplier Supplier { get; set; } 23 | public float GrossTotal { get; set; } 24 | 25 | [DefaultValue(0)] 26 | public float TotalDiscout { get; set; } 27 | 28 | [DefaultValue(0)] 29 | public float Returns { get; set; } 30 | 31 | public float NetTotal { get; set; } 32 | public int Status { get; set; } 33 | public virtual Employee Employee { get; set; } 34 | 35 | [MaxLength(30)] 36 | public string ChequeNo { get; set; } 37 | 38 | [DefaultValue(0)] 39 | public float PaidAmount { get; set; } 40 | 41 | [DefaultValue(0)] 42 | public float PendingAmount { get; set; } 43 | 44 | public string Remarks { get; set; } 45 | } 46 | } -------------------------------------------------------------------------------- /SimpleBilling/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("SimpleBilling")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("SimpleBilling")] 13 | [assembly: AssemblyCopyright("Copyright © 2020")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("06c94ac4-46c2-416a-9bee-7fa2ce77e708")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /SimpleBilling/Model/ReceiptHeader.cs: -------------------------------------------------------------------------------- 1 | using System.ComponentModel; 2 | using System.ComponentModel.DataAnnotations; 3 | 4 | namespace SimpleBilling.Model 5 | { 6 | public class ReceiptHeader : BaseEntity 7 | { 8 | [Key] 9 | [MaxLength(200)] 10 | public string ReceiptNo { get; set; } 11 | 12 | [Required] 13 | public string Date { get; set; } 14 | 15 | [Required] 16 | public string Time { get; set; } 17 | 18 | [Required] 19 | public int Cashier { get; set; } 20 | 21 | [DefaultValue(0)] 22 | public float TotalDiscount { get; set; } 23 | 24 | public float SubTotal { get; set; } 25 | 26 | [DefaultValue(0)] 27 | public float NetTotal { get; set; } 28 | 29 | [MaxLength(10)] 30 | public string PaymentType { get; set; } 31 | 32 | [DefaultValue("No Remarks Found")] 33 | public string Remarks { get; set; } 34 | 35 | public int CustomerId { get; set; } 36 | 37 | public string VehicleNumber { get; set; } 38 | public float PaidAmount { get; set; } 39 | public float PaidValue { get; set; } 40 | public float PendingValue { get; set; } 41 | public float Balance { get; set; } 42 | 43 | [DefaultValue(0)] 44 | public int Status { get; set; } 45 | 46 | [DefaultValue(false)] 47 | public bool IsQuotation { get; set; } 48 | [DefaultValue(false)] 49 | public bool IsPaid { get; set; } 50 | 51 | [MaxLength(30)] 52 | public string ChequeNo { get; set; } 53 | } 54 | } -------------------------------------------------------------------------------- /SimpleBilling/Model/BillingContext.cs: -------------------------------------------------------------------------------- 1 | using System.Data.Entity; 2 | 3 | namespace SimpleBilling.Model 4 | { 5 | public class BillingContext : DbContext 6 | { 7 | /// 8 | /// Version 1.0.1.2 9 | /// 10 | public BillingContext() : base("name=con") 11 | { 12 | Database.SetInitializer(new BillingDBInitializer()); 13 | } 14 | 15 | public DbSet Users { get; set; } 16 | public DbSet Categories { get; set; } 17 | public DbSet Items { get; set; } 18 | public DbSet Customers { get; set; } 19 | public DbSet Suppliers { get; set; } 20 | public DbSet GRNHeaders { get; set; } 21 | public DbSet GRNDetails { get; set; } 22 | public DbSet Employee { get; set; } 23 | public DbSet ReceiptHeaders { get; set; } 24 | public DbSet ReceiptBodies { get; set; } 25 | public DbSet Shelves { get; set; } 26 | public DbSet BusinessModels { get; set; } 27 | public DbSet Vehicles { get; set; } 28 | public DbSet MileTracking { get; set; } 29 | public DbSet Cheques { get; set; } 30 | public DbSet Banks { get; set; } 31 | public DbSet Settings { get; set; } 32 | public DbSet PendingJobs { get; set; } 33 | public DbSet PurchaseOrders { get; set; } 34 | public DbSet OrderedItems { get; set; } 35 | public DbSet SmsLogs { get; set; } 36 | } 37 | } -------------------------------------------------------------------------------- /SimpleBilling/Reports/VoidedReceipts.cs: -------------------------------------------------------------------------------- 1 | using SimpleBilling.Model; 2 | using System; 3 | using System.Linq; 4 | using System.Windows.Forms; 5 | 6 | namespace SimpleBilling.Reports 7 | { 8 | public partial class VoidedReceipts : Form 9 | { 10 | public VoidedReceipts() 11 | { 12 | InitializeComponent(); 13 | } 14 | 15 | private void VoidedReceipts_Load(object sender, EventArgs e) 16 | { 17 | 18 | } 19 | 20 | private void FilterByDate(string FromDate, string ToDate) 21 | { 22 | using (BillingContext db = new BillingContext()) 23 | { 24 | //var data = (from header in db.ReceiptHeaders.Where(c => !c.IsDeleted && !c.IsQuotation & c.Status == 0) 25 | // join cashier in db.Employee 26 | // on header.Cashier equals cashier.EmployeeId 27 | // join cus in db.Customers 28 | // on header.CustomerId equals cus.CustomerId 29 | // select new 30 | // { 31 | // header.ReceiptNo, 32 | // header.Date, 33 | // header.Time, 34 | // cashier.EmployeeName, 35 | // cus.Name, 36 | // header.SubTotal, 37 | // header.TotalDiscount, 38 | // header.NetTotal, 39 | // header.PaymentType 40 | // }).Where(c=>c.Date == ).ToList(); 41 | //DGVReport.DataSource = data; 42 | } 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /SimpleBilling/App.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 |
6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | # Set default behavior to automatically normalize line endings. 3 | ############################################################################### 4 | * text=auto 5 | 6 | ############################################################################### 7 | # Set default behavior for command prompt diff. 8 | # 9 | # This is need for earlier builds of msysgit that does not have it on by 10 | # default for csharp files. 11 | # Note: This is only used by command line 12 | ############################################################################### 13 | #*.cs diff=csharp 14 | 15 | ############################################################################### 16 | # Set the merge driver for project and solution files 17 | # 18 | # Merging from the command prompt will add diff markers to the files if there 19 | # are conflicts (Merging from VS is not affected by the settings below, in VS 20 | # the diff markers are never inserted). Diff markers may cause the following 21 | # file extensions to fail to load in VS. An alternative would be to treat 22 | # these files as binary and thus will always conflict and require user 23 | # intervention with every merge. To do so, just uncomment the entries below 24 | ############################################################################### 25 | #*.sln merge=binary 26 | #*.csproj merge=binary 27 | #*.vbproj merge=binary 28 | #*.vcxproj merge=binary 29 | #*.vcproj merge=binary 30 | #*.dbproj merge=binary 31 | #*.fsproj merge=binary 32 | #*.lsproj merge=binary 33 | #*.wixproj merge=binary 34 | #*.modelproj merge=binary 35 | #*.sqlproj merge=binary 36 | #*.wwaproj merge=binary 37 | 38 | ############################################################################### 39 | # behavior for image files 40 | # 41 | # image files are treated as binary by default. 42 | ############################################################################### 43 | #*.jpg binary 44 | #*.png binary 45 | #*.gif binary 46 | 47 | ############################################################################### 48 | # diff behavior for common document formats 49 | # 50 | # Convert binary document formats to text before diffing them. This feature 51 | # is only available from the command line. Turn it on by uncommenting the 52 | # entries below. 53 | ############################################################################### 54 | #*.doc diff=astextplain 55 | #*.DOC diff=astextplain 56 | #*.docx diff=astextplain 57 | #*.DOCX diff=astextplain 58 | #*.dot diff=astextplain 59 | #*.DOT diff=astextplain 60 | #*.pdf diff=astextplain 61 | #*.PDF diff=astextplain 62 | #*.rtf diff=astextplain 63 | #*.RTF diff=astextplain 64 | -------------------------------------------------------------------------------- /SimpleBilling/SMS/Sender.cs: -------------------------------------------------------------------------------- 1 | using iText.Layout.Element; 2 | using SimpleBilling.Model; 3 | using System; 4 | using System.Data.Entity; 5 | using System.Diagnostics; 6 | using System.Net; 7 | using System.Web; 8 | using System.Windows.Forms; 9 | 10 | namespace SimpleBilling.SMS 11 | { 12 | public static class Sender 13 | { 14 | private static string Username = "New_city"; 15 | private static string Password = "NCI@123"; 16 | private static string CallerId = "CAR WEST"; 17 | public static void Send(string DNumber, string Message) 18 | { 19 | try 20 | { 21 | if (DNumber.StartsWith("0")) 22 | { 23 | DNumber = DNumber.Remove(0, 1); 24 | } 25 | if (!DNumber.StartsWith("94")) 26 | { 27 | DNumber = "94" + DNumber; 28 | } 29 | 30 | try 31 | { 32 | string request = "https://bulksms2.etisalat.lk/sendsmsmultimask.php?"; 33 | var postData = "USER=" + HttpUtility.UrlPathEncode(Username) + "&PWD=" + HttpUtility.UrlPathEncode(Password) + "&MASK=" + HttpUtility.UrlPathEncode(CallerId) + "&NUM=" + HttpUtility.UrlPathEncode(DNumber) + "&MSG=" + HttpUtility.UrlDecode(Message); 34 | 35 | using (var web = new WebClient()) 36 | { 37 | Debug.WriteLine(request + postData); 38 | string result = web.DownloadString(request + postData); 39 | using (BillingContext db = new BillingContext()) 40 | { 41 | SMSLog log = new SMSLog 42 | { 43 | CreatedDate = DateTime.Today, 44 | LogKey = Rand.RandomString(15), 45 | LogMessage = Message, 46 | Log = result, 47 | Number = DNumber 48 | }; 49 | if (db.Entry(log).State == EntityState.Detached) 50 | db.Set().Attach(log); 51 | db.Entry(log).State = EntityState.Added; 52 | db.SaveChanges(); 53 | } 54 | } 55 | } 56 | catch (Exception ex) 57 | { 58 | Info.Mes(ex.Message); 59 | return; 60 | } 61 | } 62 | catch (Exception ex) 63 | { 64 | Info.Mes(ex.Message); 65 | } 66 | } 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /SimpleBilling/MasterForms/CustomerLookUp.cs: -------------------------------------------------------------------------------- 1 | using SimpleBilling.Model; 2 | using System; 3 | using System.Data; 4 | using System.Linq; 5 | using System.Windows.Forms; 6 | 7 | namespace SimpleBilling.MasterForms 8 | { 9 | public partial class CustomerLookUp : Form 10 | { 11 | public string CustomerId { get; set; } 12 | public string CustomerName { get; set; } 13 | public CustomerLookUp() 14 | { 15 | InitializeComponent(); 16 | } 17 | 18 | private void CustomerLookUp_Load(object sender, EventArgs e) 19 | { 20 | LoadAllCustomers(string.Empty); 21 | } 22 | 23 | private void LoadAllCustomers(string Input) 24 | { 25 | try 26 | { 27 | if (string.IsNullOrWhiteSpace(Input)) 28 | { 29 | using (BillingContext db = new BillingContext()) 30 | { 31 | var data = (from i in db.Customers.Where(c => !c.IsDeleted) 32 | select new 33 | { 34 | i.CustomerId, 35 | i.Name 36 | }).ToList(); 37 | DGVCustomers.DataSource = data; 38 | } 39 | } 40 | else 41 | { 42 | using (BillingContext db = new BillingContext()) 43 | { 44 | var data = (from i in db.Customers.Where(c => c.Name.Contains(Input) && !c.IsDeleted) 45 | select new 46 | { 47 | i.CustomerId, 48 | i.Name 49 | }).ToList(); 50 | DGVCustomers.DataSource = data; 51 | } 52 | } 53 | } 54 | catch (Exception ex) 55 | { 56 | Info.Mes(ex.Message); 57 | } 58 | } 59 | 60 | private void TxtSearchCustomers_KeyUp(object sender, KeyEventArgs e) 61 | { 62 | TxtSearchCustomers.Text.Trim(); 63 | LoadAllCustomers(TxtSearchCustomers.Text.Trim()); 64 | } 65 | 66 | private void DGVCustomers_CellClick(object sender, DataGridViewCellEventArgs e) 67 | { 68 | if (DGVCustomers.SelectedRows.Count > 0) 69 | { 70 | CustomerId = DGVCustomers.SelectedRows[0].Cells[0].Value + string.Empty; 71 | CustomerName = DGVCustomers.SelectedRows[0].Cells[1].Value + string.Empty; 72 | } 73 | } 74 | 75 | private void BtnOk_Click(object sender, EventArgs e) 76 | { 77 | 78 | } 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /SimpleBilling/Properties/Resources.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.42000 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace SimpleBilling.Properties { 12 | using System; 13 | 14 | 15 | /// 16 | /// A strongly-typed resource class, for looking up localized strings, etc. 17 | /// 18 | // This class was auto-generated by the StronglyTypedResourceBuilder 19 | // class via a tool like ResGen or Visual Studio. 20 | // To add or remove a member, edit your .ResX file then rerun ResGen 21 | // with the /str option, or rebuild your VS project. 22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")] 23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 25 | internal class Resources { 26 | 27 | private static global::System.Resources.ResourceManager resourceMan; 28 | 29 | private static global::System.Globalization.CultureInfo resourceCulture; 30 | 31 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] 32 | internal Resources() { 33 | } 34 | 35 | /// 36 | /// Returns the cached ResourceManager instance used by this class. 37 | /// 38 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 39 | internal static global::System.Resources.ResourceManager ResourceManager { 40 | get { 41 | if (object.ReferenceEquals(resourceMan, null)) { 42 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("SimpleBilling.Properties.Resources", typeof(Resources).Assembly); 43 | resourceMan = temp; 44 | } 45 | return resourceMan; 46 | } 47 | } 48 | 49 | /// 50 | /// Overrides the current thread's CurrentUICulture property for all 51 | /// resource lookups using this strongly typed resource class. 52 | /// 53 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 54 | internal static global::System.Globalization.CultureInfo Culture { 55 | get { 56 | return resourceCulture; 57 | } 58 | set { 59 | resourceCulture = value; 60 | } 61 | } 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /SimpleBilling/Properties/app.manifest: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 48 | 55 | 56 | 70 | -------------------------------------------------------------------------------- /SimpleBilling/ExportJSON.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | using SimpleBilling.Model; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.IO; 6 | using System.Linq; 7 | 8 | namespace SimpleBilling 9 | { 10 | public static class ExportJson 11 | { 12 | public static void Add(Exception ex) 13 | { 14 | try 15 | { 16 | using (BillingContext db = new BillingContext()) 17 | { 18 | Setting data = db.Settings.Take(1).FirstOrDefault(); 19 | if (data == null) return; 20 | string path = data.ExceptionPath; 21 | string fileName = path + "exception.json"; 22 | string rawJson; 23 | if (!File.Exists(fileName)) 24 | { 25 | File.Create(fileName); 26 | } 27 | 28 | rawJson = File.ReadAllText(fileName); 29 | var ec = JsonConvert.DeserializeObject(rawJson); 30 | 31 | if (ec != null) 32 | { 33 | int Count = ec.Exceptions.Count; 34 | Exp Exps = new Exp 35 | { 36 | Id = ++Count, 37 | Time = DateTime.Now.ToShortTimeString(), 38 | Date = DateTime.Today.ToShortDateString(), 39 | Message = ex.Message.ToString(), 40 | StackTrace = ex.StackTrace.ToString() 41 | }; 42 | ec.Exceptions.Add(Exps); 43 | string serializedJson = JsonConvert.SerializeObject(ec, Formatting.Indented); 44 | File.WriteAllText(path, serializedJson); 45 | } 46 | else 47 | { 48 | ExpCollection exp = new ExpCollection 49 | { 50 | Exceptions = new List() 51 | }; 52 | Exp Exps = new Exp 53 | { 54 | Id = 1, 55 | Time = DateTime.Now.ToShortTimeString(), 56 | Date = DateTime.Today.ToShortDateString(), 57 | Message = ex.Message.ToString(), 58 | StackTrace = ex.StackTrace.ToString() 59 | }; 60 | exp.Exceptions.Add(Exps); 61 | string serializedJson = JsonConvert.SerializeObject(exp, Formatting.Indented); 62 | File.WriteAllText(path, serializedJson); 63 | } 64 | } 65 | } 66 | catch (Exception e) 67 | { 68 | Add(e); 69 | } 70 | finally 71 | { 72 | Info.Mes(ex.Message); 73 | } 74 | } 75 | } 76 | 77 | public class ExpCollection 78 | { 79 | public List Exceptions { get; set; } 80 | } 81 | 82 | public class ConnectionString 83 | { 84 | public string Database { get; set; } 85 | public string Source { get; set; } 86 | public bool IntegratedSecurity { get; set; } 87 | public string UserId { get; set; } 88 | public string Password { get; set; } 89 | } 90 | 91 | public class Exp 92 | { 93 | [JsonProperty] 94 | public int Id { get; set; } 95 | 96 | [JsonProperty] 97 | public string Time { get; set; } 98 | 99 | [JsonProperty] 100 | public string Date { get; set; } 101 | 102 | [JsonProperty] 103 | public string Message { get; set; } 104 | 105 | [JsonProperty] 106 | public string StackTrace { get; set; } 107 | } 108 | } -------------------------------------------------------------------------------- /SimpleBilling/ExportJson.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | using SimpleBilling.Model; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.IO; 6 | using System.Linq; 7 | 8 | namespace SimpleBilling 9 | { 10 | public static class ExportJson 11 | { 12 | public static void Add(Exception ex) 13 | { 14 | try 15 | { 16 | using (BillingContext db = new BillingContext()) 17 | { 18 | Setting data = db.Settings.Take(1).FirstOrDefault(); 19 | if (data == null) return; 20 | string path = data.ExceptionPath; 21 | string fileName = path + "exception.json"; 22 | string rawJson; 23 | if (!File.Exists(fileName)) 24 | { 25 | File.Create(fileName); 26 | } 27 | 28 | rawJson = File.ReadAllText(fileName); 29 | var ec = JsonConvert.DeserializeObject(rawJson); 30 | 31 | if (ec != null) 32 | { 33 | int Count = ec.Exceptions.Count; 34 | Exp Exps = new Exp 35 | { 36 | Id = ++Count, 37 | Time = DateTime.Now.ToShortTimeString(), 38 | Date = DateTime.Today.ToShortDateString(), 39 | Message = ex.Message.ToString(), 40 | StackTrace = ex.StackTrace.ToString() 41 | }; 42 | ec.Exceptions.Add(Exps); 43 | string serializedJson = JsonConvert.SerializeObject(ec, Formatting.Indented); 44 | File.WriteAllText(path, serializedJson); 45 | } 46 | else 47 | { 48 | ExpCollection exp = new ExpCollection 49 | { 50 | Exceptions = new List() 51 | }; 52 | Exp Exps = new Exp 53 | { 54 | Id = 1, 55 | Time = DateTime.Now.ToShortTimeString(), 56 | Date = DateTime.Today.ToShortDateString(), 57 | Message = ex.Message.ToString(), 58 | StackTrace = ex.StackTrace.ToString() 59 | }; 60 | exp.Exceptions.Add(Exps); 61 | string serializedJson = JsonConvert.SerializeObject(exp, Formatting.Indented); 62 | File.WriteAllText(path, serializedJson); 63 | } 64 | } 65 | } 66 | catch (Exception e) 67 | { 68 | Add(e); 69 | } 70 | finally 71 | { 72 | Info.Mes(ex.Message); 73 | } 74 | } 75 | } 76 | 77 | public class ExpCollection 78 | { 79 | public List Exceptions { get; set; } 80 | } 81 | 82 | public class ConnectionString 83 | { 84 | public string Database { get; set; } 85 | public string Source { get; set; } 86 | public bool IntegratedSecurity { get; set; } 87 | public string UserId { get; set; } 88 | public string Password { get; set; } 89 | } 90 | 91 | public class Exp 92 | { 93 | [JsonProperty] 94 | public int Id { get; set; } 95 | 96 | [JsonProperty] 97 | public string Time { get; set; } 98 | 99 | [JsonProperty] 100 | public string Date { get; set; } 101 | 102 | [JsonProperty] 103 | public string Message { get; set; } 104 | 105 | [JsonProperty] 106 | public string StackTrace { get; set; } 107 | } 108 | } -------------------------------------------------------------------------------- /SimpleBilling/MasterForms/ItemLookup.cs: -------------------------------------------------------------------------------- 1 | using SimpleBilling.Model; 2 | using System; 3 | using System.ComponentModel; 4 | using System.Data; 5 | using System.Data.Entity; 6 | using System.Linq; 7 | using System.Windows.Forms; 8 | 9 | namespace SimpleBilling.MasterForms 10 | { 11 | public partial class ItemLookup : Form 12 | { 13 | public string Code { get; set; } 14 | public string ItemName { get; set; } 15 | public ItemLookup() 16 | { 17 | InitializeComponent(); 18 | } 19 | 20 | private void ItemLookup_Load(object sender, EventArgs e) 21 | { 22 | FormLoad(); 23 | } 24 | 25 | private async void FormLoad() 26 | { 27 | TxtItemLookUp.Focus(); 28 | using (BillingContext db = new BillingContext()) 29 | { 30 | var data = await (from i in db.Items.Where(c => !c.IsDeleted) 31 | select new 32 | { 33 | i.Code, 34 | i.ItemName 35 | }).ToListAsync(); 36 | DGVItems.DataSource = data; 37 | } 38 | } 39 | 40 | private void LoadAllItems() 41 | { 42 | using (BillingContext db = new BillingContext()) 43 | { 44 | var data = (from i in db.Items.Where(c => !c.IsDeleted) 45 | select new 46 | { 47 | i.Code, 48 | i.ItemName 49 | }).ToList(); 50 | DGVItems.DataSource = data; 51 | } 52 | } 53 | 54 | private void SearchItems(string Input) 55 | { 56 | using (BillingContext db = new BillingContext()) 57 | { 58 | var data = (from i in db.Items.Where(c => (c.Code.Contains(Input) || c.ItemName.Contains(Input)) && !c.IsDeleted) 59 | select new 60 | { 61 | i.Code, 62 | i.ItemName 63 | }).ToList(); 64 | DGVItems.DataSource = data; 65 | } 66 | } 67 | 68 | private void TxtItemLookUp_KeyUp(object sender, KeyEventArgs e) 69 | { 70 | if (TxtItemLookUp.Text.Length > 0) 71 | { 72 | SearchItems(TxtItemLookUp.Text.Trim()); 73 | } 74 | else 75 | { 76 | LoadAllItems(); 77 | } 78 | } 79 | 80 | private void DGVItems_CellDoubleClick(object sender, DataGridViewCellEventArgs e) 81 | { 82 | if (DGVItems.SelectedRows.Count > 0) 83 | { 84 | Code = DGVItems.SelectedRows[0].Cells[0].Value + string.Empty; 85 | ItemName = DGVItems.SelectedRows[0].Cells[1].Value + string.Empty; 86 | } 87 | } 88 | 89 | private void DGVItems_CellClick(object sender, DataGridViewCellEventArgs e) 90 | { 91 | if (DGVItems.SelectedRows.Count > 0) 92 | { 93 | Code = DGVItems.SelectedRows[0].Cells[0].Value + string.Empty; 94 | ItemName = DGVItems.SelectedRows[0].Cells[1].Value + string.Empty; 95 | } 96 | } 97 | 98 | private void DGVItems_MouseClick(object sender, MouseEventArgs e) 99 | { 100 | if (DGVItems.SelectedRows.Count > 0) 101 | { 102 | Code = DGVItems.SelectedRows[0].Cells[0].Value + string.Empty; 103 | ItemName = DGVItems.SelectedRows[0].Cells[1].Value + string.Empty; 104 | } 105 | } 106 | 107 | private void BtnOk_Click(object sender, EventArgs e) 108 | { 109 | 110 | } 111 | } 112 | } 113 | -------------------------------------------------------------------------------- /SimpleBilling/Login.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Windows.Forms; 5 | using SimpleBilling.Model; 6 | 7 | namespace SimpleBilling.MasterForms 8 | { 9 | public partial class Login : Form 10 | { 11 | public Login() 12 | { 13 | InitializeComponent(); 14 | using (var db = new BillingContext()) 15 | { 16 | var employee = db.Employee.Take(1).FirstOrDefault(); 17 | if (employee == null) 18 | { 19 | IList emp = new List 20 | { 21 | new Employee() 22 | { 23 | EmployeeName = "Fazrin", 24 | Contact = "0772949123", 25 | Address = "412, Bulugohotenne, Batugoda, Kandy", 26 | Email = "mfmfazrin1986@gmail.com", 27 | SecretCode = "2222", 28 | Status = 0, 29 | CreatedDate = DateTime.Today 30 | }, 31 | new Employee() 32 | { 33 | EmployeeName = "Razmy", 34 | Contact = "0772949123", 35 | Address = "412, Bulugohotenne, Batugoda, Kandy", 36 | Email = "razmy@gmail.com", 37 | SecretCode = "3333", 38 | Status = 0, 39 | CreatedDate = DateTime.Today 40 | } 41 | }; 42 | db.Employee.AddRange(emp); 43 | db.SaveChanges(); 44 | } 45 | 46 | var user = db.Users.Take(1).FirstOrDefault(); 47 | if (user == null) 48 | { 49 | IList users = new List 50 | { 51 | new Users() { Username = "Admin", Password = "12345", UserType = 1, EmployeeId = 1 }, 52 | new Users() { Username = "User", Password = "12345", UserType = 2, EmployeeId = 2 } 53 | }; 54 | db.Users.AddRange(users); 55 | db.SaveChanges(); 56 | } 57 | } 58 | } 59 | 60 | private void Login_Load(object sender, EventArgs e) 61 | { 62 | TxtLogin.Focus(); 63 | } 64 | 65 | private void BtnLogin_Click(object sender, EventArgs e) 66 | { 67 | try 68 | { 69 | CashierLogin(); 70 | } 71 | catch (Exception ex) 72 | { 73 | ExportJson.Add(ex); 74 | Info.Mes(ex.Message); 75 | } 76 | } 77 | 78 | private void CashierLogin() 79 | { 80 | try 81 | { 82 | using (BillingContext db = new BillingContext()) 83 | { 84 | if (Info.IsEmpty(TxtLogin)) 85 | { 86 | var data = db.Employee.FirstOrDefault(c => c.SecretCode == TxtLogin.Text.Trim()); 87 | if (data != null) 88 | { 89 | Info.CashierId = data.EmployeeId; 90 | Info.UserType = 3; 91 | Main m = new Main(); 92 | m.Show(); 93 | Hide(); 94 | } 95 | else 96 | { 97 | Info.Mes("Pass code is not valid, Please try again"); 98 | } 99 | } 100 | } 101 | } 102 | catch (Exception ex) 103 | { 104 | ExportJson.Add(ex); 105 | } 106 | } 107 | 108 | private void TxtLogin_KeyDown(object sender, KeyEventArgs e) 109 | { 110 | if (e.KeyCode == Keys.Enter) 111 | { 112 | CashierLogin(); 113 | } 114 | } 115 | 116 | private void BtnExit_Click(object sender, EventArgs e) 117 | { 118 | Application.Exit(); 119 | } 120 | 121 | private void BtnAdminExit_Click(object sender, EventArgs e) 122 | { 123 | Application.Exit(); 124 | } 125 | 126 | private void BtnAdminLogin_Click(object sender, EventArgs e) 127 | { 128 | LoginFunction(); 129 | } 130 | 131 | private void LoginFunction() 132 | { 133 | using (BillingContext db = new BillingContext()) 134 | { 135 | string UName = TxtUsername.Text.Trim(); 136 | string PWord = TxtPassword.Text.Trim(); 137 | var users = db.Users.FirstOrDefault(c => c.Username == UName && c.Password == PWord && !c.IsDeleted); 138 | if (users != null) 139 | { 140 | Info.CashierId = users.EmployeeId; 141 | Info.UserType = users.UserType; 142 | Main m = new Main(); 143 | m.Show(); 144 | Hide(); 145 | } 146 | else 147 | { 148 | Info.Mes("Username or password not valid, Please try again"); 149 | } 150 | } 151 | } 152 | 153 | private void TxtPassword_KeyDown(object sender, KeyEventArgs e) 154 | { 155 | if (e.KeyCode == Keys.Enter) 156 | { 157 | LoginFunction(); 158 | } 159 | } 160 | } 161 | } -------------------------------------------------------------------------------- /SimpleBilling/MasterForms/ManageStock.cs: -------------------------------------------------------------------------------- 1 | using SimpleBilling.Model; 2 | using System; 3 | using System.Data.Entity; 4 | using System.Linq; 5 | using System.Windows.Forms; 6 | 7 | namespace SimpleBilling.MasterForms 8 | { 9 | public partial class ManageStock : Form 10 | { 11 | private int StockId; 12 | 13 | public ManageStock() 14 | { 15 | InitializeComponent(); 16 | } 17 | 18 | private void ManageStock_Load(object sender, EventArgs e) 19 | { 20 | DGVLoad(); 21 | } 22 | 23 | private void DGVLoad() 24 | { 25 | using (BillingContext db = new BillingContext()) 26 | { 27 | var data = (from i in db.Items.Where(c => !c.IsDeleted && !c.IsService) 28 | select new 29 | { 30 | i.Id, 31 | i.Code, 32 | Item_Name = i.ItemName, 33 | i.StockQty 34 | }).ToList(); 35 | DGVManageStocks.DataSource = data; 36 | } 37 | } 38 | 39 | private void DGVManageStocks_CellClick(object sender, DataGridViewCellEventArgs e) 40 | { 41 | if (DGVManageStocks.SelectedRows.Count > 0) 42 | { 43 | StockId = Convert.ToInt32(DGVManageStocks.SelectedRows[0].Cells[0].Value + string.Empty); 44 | TxtUpdateStockCount.Text = DGVManageStocks.SelectedRows[0].Cells[3].Value + string.Empty; 45 | } 46 | } 47 | 48 | private void TxtFilterProducts_KeyUp(object sender, KeyEventArgs e) 49 | { 50 | Info.ToCapital(TxtFilterProducts); 51 | Filter(); 52 | } 53 | 54 | private void Filter() 55 | { 56 | try 57 | { 58 | string Filter = TxtFilterProducts.Text.Trim(); 59 | using (BillingContext db = new BillingContext()) 60 | { 61 | if (Filter.Length > 0) 62 | { 63 | var data = (from i in db.Items 64 | .Where(c => c.Code.Contains(Filter) 65 | || c.Barcode.Contains(Filter) 66 | || c.ItemName.Contains(Filter) 67 | && !c.IsDeleted && !c.IsService) 68 | select new 69 | { 70 | i.Id, 71 | i.Code, 72 | Item_Name = i.ItemName, 73 | i.StockQty 74 | }).ToList(); 75 | DGVManageStocks.DataSource = data; 76 | } 77 | else 78 | { 79 | var data = (from i in db.Items.Where(c => !c.IsDeleted && !c.IsService) 80 | select new 81 | { 82 | i.Id, 83 | i.Code, 84 | Item_Name = i.ItemName, 85 | i.StockQty 86 | }).ToList(); 87 | DGVManageStocks.DataSource = data; 88 | } 89 | } 90 | } 91 | catch (Exception ex) 92 | { 93 | ExportJson.Add(ex); 94 | Info.Mes(ex.Message); 95 | } 96 | } 97 | 98 | private void BtnUpdate_Click(object sender, EventArgs e) 99 | { 100 | try 101 | { 102 | DialogResult dialogResult = MessageBox.Show("Are you sure you want to update this stock quantity?", "Confirmation Update", MessageBoxButtons.YesNo); 103 | if (dialogResult == DialogResult.Yes) 104 | { 105 | using (BillingContext db = new BillingContext()) 106 | { 107 | if (DGVManageStocks.SelectedRows.Count > 0) 108 | { 109 | var data = db.Items.FirstOrDefault(c => c.Id == StockId); 110 | if (data != null) 111 | { 112 | if (Info.IsEmpty(TxtUpdateStockCount)) 113 | { 114 | data.StockQty = Convert.ToInt32(TxtUpdateStockCount.Text.Trim()); 115 | if (db.Entry(data).State == EntityState.Detached) 116 | db.Set().Attach(data); 117 | db.Entry(data).State = EntityState.Modified; 118 | db.SaveChanges(); 119 | } 120 | else 121 | { 122 | Info.Mes("Please enter a new quantity to update new value"); 123 | } 124 | } 125 | } 126 | else 127 | { 128 | Info.Mes("Please enter a new quantity to update new value"); 129 | } 130 | } 131 | } 132 | } 133 | catch (Exception ex) 134 | { 135 | ExportJson.Add(ex); 136 | Info.Mes(ex.Message); 137 | } 138 | finally 139 | { 140 | DGVLoad(); 141 | } 142 | } 143 | } 144 | } -------------------------------------------------------------------------------- /SimpleBilling/Properties/Resources.resx: -------------------------------------------------------------------------------- 1 | 2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | text/microsoft-resx 107 | 108 | 109 | 2.0 110 | 111 | 112 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 113 | 114 | 115 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | -------------------------------------------------------------------------------- /SimpleBilling/MasterForms/ManageShelves.cs: -------------------------------------------------------------------------------- 1 | using SimpleBilling.Model; 2 | using System; 3 | using System.Data.Entity; 4 | using System.Linq; 5 | using System.Windows.Forms; 6 | 7 | namespace SimpleBilling.MasterForms 8 | { 9 | public partial class ManageShelves : Form 10 | { 11 | public ManageShelves() 12 | { 13 | InitializeComponent(); 14 | } 15 | 16 | private void ManageShelves_Load(object sender, EventArgs e) 17 | { 18 | LoadDGV(); 19 | Init(); 20 | } 21 | 22 | private void LoadDGV() 23 | { 24 | using (BillingContext db = new BillingContext()) 25 | { 26 | shelfBindingSource.DataSource = db.Shelves.Where(c => !c.IsDeleted).ToList(); 27 | } 28 | } 29 | 30 | private void Init() 31 | { 32 | PanelCRUD.Enabled = false; 33 | BtnSave.Enabled = false; 34 | BtnDelete.Enabled = false; 35 | LblMessage.Text = string.Empty; 36 | } 37 | 38 | private void Delete() 39 | { 40 | if (DGVShelf.SelectedRows.Count > 0) 41 | { 42 | BtnDelete.Enabled = true; 43 | } 44 | } 45 | 46 | private void DGVShelf_CellClick(object sender, DataGridViewCellEventArgs e) 47 | { 48 | Delete(); 49 | } 50 | 51 | private void ManageShelves_Click(object sender, EventArgs e) 52 | { 53 | Save(); 54 | } 55 | 56 | private void BtnAdd_Click(object sender, EventArgs e) 57 | { 58 | Add(); 59 | } 60 | 61 | private void Add() 62 | { 63 | shelfBindingSource.Add(new Shelf()); 64 | shelfBindingSource.MoveLast(); 65 | Edit(); 66 | } 67 | 68 | private void BtnEdit_Click(object sender, EventArgs e) 69 | { 70 | Edit(); 71 | } 72 | 73 | private void Edit() 74 | { 75 | PanelCRUD.Enabled = true; 76 | BtnAdd.Enabled = false; 77 | BtnEdit.Enabled = false; 78 | BtnDelete.Enabled = false; 79 | BtnSave.Enabled = true; 80 | TxtShelfName.Focus(); 81 | } 82 | 83 | private void BtnDelete_Click(object sender, EventArgs e) 84 | { 85 | try 86 | { 87 | DialogResult dialogResult = MessageBox.Show("Are you sure you want to delete the selected row?", "Confirmation delete", MessageBoxButtons.YesNo); 88 | if (dialogResult == DialogResult.Yes) 89 | { 90 | using (BillingContext db = new BillingContext()) 91 | { 92 | int Id = Convert.ToInt32(TxtId.Text.Trim().ToString()); 93 | Shelf shelve = db.Shelves.FirstOrDefault(s => s.ShelfId == Id); 94 | if (shelve != null) 95 | { 96 | shelve.IsDeleted = true; 97 | shelve.UpdatedDate = DateTime.Now; 98 | db.Entry(shelve).State = EntityState.Modified; 99 | db.SaveChanges(); 100 | Message("Shelve Deleted Successfully"); 101 | } 102 | } 103 | } 104 | } 105 | catch (Exception ex) 106 | { 107 | ExportJson.Add(ex); 108 | Message(ex.ToString()); 109 | } 110 | finally 111 | { 112 | DGVShelf.Refresh(); 113 | LoadDGV(); 114 | } 115 | } 116 | 117 | private void Message(string Message) 118 | { 119 | LblMessage.Text = Message; 120 | } 121 | 122 | private void MessageTimer_Tick(object sender, EventArgs e) 123 | { 124 | LblMessage.Text = string.Empty; 125 | } 126 | 127 | private void BtnSave_Click(object sender, EventArgs e) 128 | { 129 | SaveItem(); 130 | } 131 | 132 | private void SaveItem() 133 | { 134 | try 135 | { 136 | using (BillingContext db = new BillingContext()) 137 | { 138 | if (shelfBindingSource.Current is Shelf shelve) 139 | { 140 | if (db.Entry(shelve).State == EntityState.Detached) 141 | db.Set().Attach(shelve); 142 | if (shelve.ShelfId == 0) 143 | { 144 | shelve.CreatedDate = DateTime.Now; 145 | db.Entry(shelve).State = EntityState.Added; 146 | Message("Shelf Added"); 147 | } 148 | else 149 | { 150 | shelve.UpdatedDate = DateTime.Now; 151 | db.Entry(shelve).State = EntityState.Modified; 152 | Message("Shelf Modified"); 153 | } 154 | db.SaveChanges(); 155 | } 156 | } 157 | } 158 | catch (Exception ex) 159 | { 160 | ExportJson.Add(ex); 161 | Message(ex.Message); 162 | } 163 | finally 164 | { 165 | LoadDGV(); 166 | Save(); 167 | } 168 | } 169 | 170 | private void Save() 171 | { 172 | BtnSave.Enabled = false; 173 | PanelCRUD.Enabled = false; 174 | BtnAdd.Enabled = true; 175 | BtnEdit.Enabled = true; 176 | } 177 | 178 | private void TxtShelfName_KeyUp(object sender, KeyEventArgs e) 179 | { 180 | Info.ToCapital(TxtShelfName); 181 | } 182 | } 183 | } -------------------------------------------------------------------------------- /SimpleBilling/Login.resx: -------------------------------------------------------------------------------- 1 | 2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | text/microsoft-resx 110 | 111 | 112 | 2.0 113 | 114 | 115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | 118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 119 | 120 | -------------------------------------------------------------------------------- /SimpleBilling/MasterForms/ManageBanks.resx: -------------------------------------------------------------------------------- 1 | 2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | text/microsoft-resx 110 | 111 | 112 | 2.0 113 | 114 | 115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | 118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 119 | 120 | -------------------------------------------------------------------------------- /SimpleBilling/MasterForms/Settings.resx: -------------------------------------------------------------------------------- 1 | 2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | text/microsoft-resx 110 | 111 | 112 | 2.0 113 | 114 | 115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | 118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 119 | 120 | -------------------------------------------------------------------------------- /SimpleBilling/MasterForms/ManageCategory.cs: -------------------------------------------------------------------------------- 1 | using SimpleBilling.Model; 2 | using System; 3 | using System.Data.Entity; 4 | using System.Linq; 5 | using System.Windows.Forms; 6 | 7 | namespace SimpleBilling.MasterForms 8 | { 9 | public partial class ManageCategory : Form 10 | { 11 | private int CatId; 12 | 13 | public ManageCategory() 14 | { 15 | InitializeComponent(); 16 | } 17 | 18 | private void ManageCategory_Load(object sender, EventArgs e) 19 | { 20 | LoadDGV(); 21 | } 22 | 23 | private void LoadDGV() 24 | { 25 | PanelCRUD.Enabled = false; 26 | using (BillingContext db = new BillingContext()) 27 | { 28 | var dgv = (from cat in db.Categories.Where(c => !c.IsDeleted) 29 | select new 30 | { 31 | cat.CategoryId, 32 | cat.CategoryName 33 | }).ToList(); 34 | DGVCategories.DataSource = dgv; 35 | } 36 | } 37 | 38 | private void BtnAdd_Click(object sender, EventArgs e) 39 | { 40 | PanelCRUD.Enabled = true; 41 | if (Info.UserType == 3) 42 | { 43 | BtnEdit.Enabled = false; 44 | BtnDelete.Enabled = false; 45 | } 46 | BtnSave.Enabled = true; 47 | TxtCategoryName.Text = string.Empty; 48 | TxtCategoryName.Focus(); 49 | TxtCatId.Text = "0"; 50 | } 51 | 52 | private void BtnEdit_Click(object sender, EventArgs e) 53 | { 54 | PanelCRUD.Enabled = true; 55 | BtnSave.Enabled = true; 56 | TxtCategoryName.Focus(); 57 | } 58 | 59 | private void BtnDelete_Click(object sender, EventArgs e) 60 | { 61 | try 62 | { 63 | DialogResult dialogResult = MessageBox.Show("Are you sure you want to delete the selected Item?", "Confirmation delete", MessageBoxButtons.YesNo); 64 | if (dialogResult == DialogResult.Yes) 65 | { 66 | using (BillingContext db = new BillingContext()) 67 | { 68 | var cat = db.Categories.FirstOrDefault(c => c.CategoryId == CatId); 69 | 70 | if (cat != null) 71 | { 72 | if (db.Entry(cat).State == EntityState.Detached) 73 | db.Set().Attach(cat); 74 | cat.IsDeleted = true; 75 | cat.UpdatedDate = Info.Today(); 76 | db.Entry(cat).State = EntityState.Modified; 77 | db.SaveChanges(); 78 | Info.Mes("Category Deleted Successfully"); 79 | } 80 | } 81 | } 82 | } 83 | catch (Exception ex) 84 | { 85 | Info.Mes(ex.ToString()); 86 | } 87 | finally 88 | { 89 | DGVCategories.Refresh(); 90 | LoadDGV(); 91 | } 92 | } 93 | 94 | private void BtnSave_Click(object sender, EventArgs e) 95 | { 96 | try 97 | { 98 | if (Info.IsEmpty(TxtCatId)) CatId = Convert.ToInt32(TxtCatId.Text.Trim()); 99 | using (BillingContext db = new BillingContext()) 100 | { 101 | Category cat = db.Categories.FirstOrDefault(c => c.CategoryId == CatId); 102 | if (cat == null) 103 | { 104 | if (Info.IsEmpty(TxtCategoryName)) 105 | { 106 | Category ca = new Category 107 | { 108 | CategoryName = TxtCategoryName.Text.Trim(), 109 | CreatedDate = Info.Today() 110 | }; 111 | if (db.Entry(ca).State == EntityState.Detached) 112 | db.Set().Attach(ca); 113 | db.Entry(ca).State = EntityState.Added; 114 | Info.Mes("Category Added"); 115 | db.SaveChanges(); 116 | } 117 | } 118 | else 119 | { 120 | if (Info.IsEmpty(TxtCategoryName)) 121 | { 122 | cat.CategoryName = TxtCategoryName.Text.Trim(); 123 | cat.UpdatedDate = Info.Today(); 124 | if (db.Entry(cat).State == EntityState.Detached) 125 | db.Set().Attach(cat); 126 | db.Entry(cat).State = EntityState.Modified; 127 | Info.Mes("Category Modified"); 128 | db.SaveChanges(); 129 | } 130 | } 131 | } 132 | } 133 | catch (Exception ex) 134 | { 135 | ExportJson.Add(ex); Info.Mes(ex.Message); 136 | } 137 | finally 138 | { 139 | DGVCategories.Refresh(); 140 | LoadDGV(); 141 | TxtCategoryName.Text = string.Empty; 142 | } 143 | } 144 | 145 | private void DGVCategories_CellClick(object sender, DataGridViewCellEventArgs e) 146 | { 147 | if (DGVCategories.SelectedRows.Count > 0) 148 | { 149 | CatId = Convert.ToInt32(DGVCategories.SelectedRows[0].Cells[0].Value + string.Empty); 150 | TxtCatId.Text = DGVCategories.SelectedRows[0].Cells[0].Value + string.Empty; 151 | TxtCategoryName.Text = DGVCategories.SelectedRows[0].Cells[1].Value + string.Empty; 152 | TxtCatId.ReadOnly = true; 153 | } 154 | } 155 | 156 | private void TxtCategoryName_KeyUp(object sender, KeyEventArgs e) 157 | { 158 | Info.ToCapital(TxtCategoryName); 159 | } 160 | } 161 | } -------------------------------------------------------------------------------- /SimpleBilling/MasterForms/ManageCheques.cs: -------------------------------------------------------------------------------- 1 | using SimpleBilling.Model; 2 | using System; 3 | using System.Data; 4 | using System.Linq; 5 | using System.Windows.Forms; 6 | 7 | namespace SimpleBilling.MasterForms 8 | { 9 | public partial class ManageCheques : Form 10 | { 11 | public ManageCheques() 12 | { 13 | InitializeComponent(); 14 | } 15 | 16 | private void ManageCheques_Load(object sender, EventArgs e) 17 | { 18 | DGVLoad(); 19 | } 20 | 21 | private void DGVLoad() 22 | { 23 | BtnSave.Enabled = false; 24 | BtnDelete.Enabled = false; 25 | BtnCancel.Enabled = false; 26 | CRUDPanel.Enabled = false; 27 | using (BillingContext db = new BillingContext()) 28 | { 29 | var data = (from ch in db.Cheques.Where(c => !c.IsDeleted) 30 | join cus in db.Customers.Where(c => !c.IsDeleted) 31 | on ch.PaidBy equals cus.CustomerId.ToString() 32 | join bk in db.Banks 33 | on ch.Bank equals bk.BankId 34 | select new 35 | { 36 | ch.ChequeNo, 37 | ch.Amount, 38 | ch.PayeeName, 39 | ch.DueDate, 40 | PaidBy = cus.Name, 41 | Bank = bk.BankName 42 | }).ToList(); 43 | DGVChequeDetails.DataSource = data; 44 | CmbPaidBy.ValueMember = "CustomerId"; 45 | CmbPaidBy.DisplayMember = "Name"; 46 | CmbPaidBy.DataSource = db.Customers.ToList(); 47 | 48 | CmbBankName.ValueMember = "BankId"; 49 | CmbBankName.DisplayMember = "BankName"; 50 | CmbBankName.DataSource = db.Banks.ToList(); 51 | } 52 | } 53 | 54 | private void BtnAdd_Click(object sender, EventArgs e) 55 | { 56 | AddEdit(); 57 | } 58 | 59 | private void AddEdit() 60 | { 61 | CRUDPanel.Enabled = true; 62 | BtnSave.Enabled = true; 63 | BtnCancel.Enabled = true; 64 | } 65 | 66 | private void BtnEdit_Click(object sender, EventArgs e) 67 | { 68 | AddEdit(); 69 | } 70 | 71 | private void BtnCancel_Click(object sender, EventArgs e) 72 | { 73 | CRUDPanel.Enabled = false; 74 | BtnSave.Enabled = false; 75 | BtnCancel.Enabled = false; 76 | BtnAdd.Enabled = true; 77 | BtnEdit.Enabled = true; 78 | } 79 | 80 | private void BtnSave_Click(object sender, EventArgs e) 81 | { 82 | try 83 | { 84 | using (BillingContext db = new BillingContext()) 85 | { 86 | var chd = db.Cheques.FirstOrDefault(c => c.ChequeNo == TxtChequeNumber.Text && !c.IsDeleted); 87 | 88 | if (chd != null) 89 | { 90 | chd.PayeeName = TxtPayeeName.Text.Trim(); 91 | chd.Amount = Convert.ToSingle(TxtChequeAmount.Text.Trim()); 92 | chd.DueDate = DTDueDate.Value.ToShortDateString(); 93 | chd.PaidBy = CmbPaidBy.SelectedValue.ToString(); 94 | chd.Bank = Convert.ToInt32(CmbBankName.SelectedValue.ToString()); 95 | chd.UpdatedDate = DateTime.Today; 96 | if (db.Entry(chd).State == System.Data.Entity.EntityState.Detached) 97 | db.Set().Attach(chd); 98 | db.Entry(chd).State = System.Data.Entity.EntityState.Modified; 99 | db.SaveChanges(); 100 | } 101 | else 102 | { 103 | Cheque ch = new Cheque 104 | { 105 | ChequeNo = TxtChequeNumber.Text.Trim(), 106 | PayeeName = TxtPayeeName.Text.Trim(), 107 | Amount = Convert.ToSingle(TxtChequeAmount.Text.Trim()), 108 | DueDate = DTDueDate.Value.ToShortDateString(), 109 | PaidBy = CmbPaidBy.SelectedValue.ToString(), 110 | Bank = Convert.ToInt32(CmbBankName.SelectedValue.ToString()), 111 | CreatedDate = DateTime.Today 112 | }; 113 | if (db.Entry(ch).State == System.Data.Entity.EntityState.Detached) 114 | db.Set().Attach(ch); 115 | db.Entry(ch).State = System.Data.Entity.EntityState.Added; 116 | db.SaveChanges(); 117 | } 118 | } 119 | } 120 | catch (Exception ex) 121 | { 122 | ExportJson.Add(ex); Info.Mes(ex.Message); 123 | } 124 | finally 125 | { 126 | DGVLoad(); 127 | } 128 | } 129 | 130 | private void BtnAddBanks_Click(object sender, EventArgs e) 131 | { 132 | ManageBanks mb = new ManageBanks(); 133 | mb.Show(); 134 | Hide(); 135 | } 136 | 137 | private void BtnLoad_Click(object sender, EventArgs e) 138 | { 139 | if (DGVChequeDetails.SelectedRows.Count > 0) 140 | { 141 | foreach (Form form in Application.OpenForms) 142 | { 143 | if (form.GetType() == typeof(POS)) 144 | { 145 | form.Activate(); 146 | return; 147 | } 148 | } 149 | 150 | POS pos = new POS(string.Empty) 151 | { 152 | MdiParent = this 153 | }; 154 | pos.Show(); 155 | } 156 | } 157 | 158 | private void ManageCheques_Activated(object sender, EventArgs e) 159 | { 160 | DGVLoad(); 161 | } 162 | 163 | private void TxtPayeeName_KeyUp(object sender, KeyEventArgs e) 164 | { 165 | Info.ToCapital(TxtPayeeName); 166 | } 167 | 168 | private void TxtChequeNumber_KeyUp(object sender, KeyEventArgs e) 169 | { 170 | Info.ToCapital(TxtChequeNumber); 171 | } 172 | } 173 | } -------------------------------------------------------------------------------- /SimpleBilling/MasterForms/GRNInvoices.cs: -------------------------------------------------------------------------------- 1 | using SimpleBilling.Model; 2 | using System; 3 | using System.Data; 4 | using System.Drawing; 5 | using System.Linq; 6 | using System.Windows.Forms; 7 | 8 | namespace SimpleBilling.MasterForms 9 | { 10 | public partial class GRNInvoices : Form 11 | { 12 | public GRNInvoices() 13 | { 14 | InitializeComponent(); 15 | } 16 | 17 | private void GRNInvoices_Load(object sender, EventArgs e) 18 | { 19 | LoadDGV(); 20 | } 21 | 22 | private void LoadDGV() 23 | { 24 | BtnLoadInvoice.Enabled = false; 25 | using (BillingContext db = new BillingContext()) 26 | { 27 | var data = (from header in db.GRNHeaders 28 | join supplier in db.Suppliers 29 | on header.Supplier.SupplierId equals supplier.SupplierId 30 | join employee in db.Employee 31 | on header.Employee.EmployeeId equals employee.EmployeeId 32 | select new 33 | { 34 | header.GRN_Id, 35 | header.GRN_No, 36 | Date = header.GRN_Date, 37 | header.IsPaid, 38 | header.Status, 39 | Supplier = supplier.Name, 40 | Created_By = employee.EmployeeName, 41 | Gross_Total = header.GrossTotal, 42 | Total_Discount = header.TotalDiscout, 43 | Net_Total = header.NetTotal 44 | }).ToList(); 45 | DGVInvoices.DataSource = data; 46 | } 47 | } 48 | 49 | private string Invoice_Status(int Status) 50 | { 51 | string CurrentStatus; 52 | if (Status == 1) 53 | { 54 | CurrentStatus = "Created"; 55 | return CurrentStatus; 56 | } 57 | else if (Status == 2) 58 | { 59 | CurrentStatus = "Completed"; 60 | return CurrentStatus; 61 | } 62 | else 63 | { 64 | CurrentStatus = "Approved"; 65 | return CurrentStatus; 66 | } 67 | } 68 | 69 | private void DGVInvoices_CellClick(object sender, DataGridViewCellEventArgs e) 70 | { 71 | if (DGVInvoices.Rows.Count > 0) 72 | { 73 | BtnLoadInvoice.Enabled = true; 74 | } 75 | } 76 | 77 | private void BtnLoadInvoice_Click(object sender, EventArgs e) 78 | { 79 | LoadGRNInvoice(); 80 | } 81 | 82 | private void LoadGRNInvoice() 83 | { 84 | string GRN_String = DGVInvoices.SelectedRows[0].Cells[1].Value + string.Empty; 85 | ManageGRN grn = new ManageGRN(GRN_String); 86 | grn.Show(); 87 | Close(); 88 | } 89 | 90 | private void DGVInvoices_CellDoubleClick(object sender, DataGridViewCellEventArgs e) 91 | { 92 | LoadGRNInvoice(); 93 | } 94 | 95 | private void BaseLayout_MouseMove(object sender, MouseEventArgs e) 96 | { 97 | Main.Count = 0; 98 | } 99 | 100 | private void DGVInvoices_MouseUp(object sender, MouseEventArgs e) 101 | { 102 | Main.Count = 0; 103 | } 104 | 105 | private void TxtSearchGRNInvoices_KeyUp(object sender, KeyEventArgs e) 106 | { 107 | if (TxtSearchGRNInvoices.Text.Length > 0) 108 | { 109 | Info.ToCapital(TxtSearchGRNInvoices); 110 | SearchDGV(TxtSearchGRNInvoices.Text.Trim()); 111 | } 112 | else 113 | { 114 | LoadDGV(); 115 | } 116 | } 117 | 118 | private void SearchDGV(string Text) 119 | { 120 | BtnLoadInvoice.Enabled = false; 121 | using (BillingContext db = new BillingContext()) 122 | { 123 | var data = (from header in db.GRNHeaders 124 | join supplier in db.Suppliers 125 | on header.Supplier.SupplierId equals supplier.SupplierId 126 | join employee in db.Employee 127 | on header.Employee.EmployeeId equals employee.EmployeeId 128 | select new 129 | { 130 | header.GRN_Id, 131 | header.GRN_No, 132 | Date = header.GRN_Date, 133 | header.IsPaid, 134 | header.Status, 135 | Supplier = supplier.Name, 136 | Created_By = employee.EmployeeName, 137 | Gross_Total = header.GrossTotal, 138 | Total_Discount = header.TotalDiscout, 139 | Net_Total = header.NetTotal 140 | }).Where(c => c.GRN_No.Contains(Text) || c.Date.Contains(Text) || c.Supplier.Contains(Text) || c.Created_By.Contains(Text)).ToList(); 141 | DGVInvoices.DataSource = data; 142 | } 143 | } 144 | 145 | private void BtnExportToExcel_Click(object sender, EventArgs e) 146 | { 147 | Info.ExportAsExcel(DGVInvoices); 148 | } 149 | 150 | private void BtnExportToPdf_Click(object sender, EventArgs e) 151 | { 152 | DataTable dt = Info.DGVToDataTable(DGVInvoices); 153 | Info.ExpPDF(dt); 154 | } 155 | 156 | private void DGVInvoices_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e) 157 | { 158 | if (e.ColumnIndex == 4 && e.Value != null) 159 | { 160 | int quantity = Convert.ToInt32(e.Value); 161 | 162 | if (quantity == 1) 163 | { 164 | e.CellStyle.BackColor = Color.Aqua; 165 | e.Value = Invoice_Status(quantity); 166 | } 167 | if (quantity == 2) 168 | { 169 | e.CellStyle.BackColor = Color.Yellow; 170 | e.Value = Invoice_Status(quantity); 171 | } 172 | if (quantity == 3) 173 | { 174 | e.CellStyle.BackColor = Color.Lime; 175 | e.Value = Invoice_Status(quantity); 176 | } 177 | } 178 | } 179 | } 180 | } -------------------------------------------------------------------------------- /SimpleBilling/MasterForms/ManageBanks.cs: -------------------------------------------------------------------------------- 1 | using SimpleBilling.Model; 2 | using System; 3 | using System.Data.Entity; 4 | using System.Linq; 5 | using System.Windows.Forms; 6 | 7 | namespace SimpleBilling.MasterForms 8 | { 9 | public partial class ManageBanks : Form 10 | { 11 | public ManageBanks() 12 | { 13 | InitializeComponent(); 14 | } 15 | 16 | 17 | 18 | private void BtnAdd_Click(object sender, EventArgs e) 19 | { 20 | CRUDPanel.Enabled = true; 21 | BtnSave.Enabled = true; 22 | BtnCancel.Enabled = true; 23 | TxtBankName.Text = string.Empty; 24 | TxtBankId.Text = "0"; 25 | } 26 | 27 | private void BtnEdit_Click(object sender, EventArgs e) 28 | { 29 | CRUDPanel.Enabled = true; 30 | BtnSave.Enabled = true; 31 | BtnCancel.Enabled = true; 32 | } 33 | 34 | private void BtnCancel_Click(object sender, EventArgs e) 35 | { 36 | CRUDPanel.Enabled = false; 37 | BtnSave.Enabled = false; 38 | BtnCancel.Enabled = false; 39 | BtnAdd.Enabled = true; 40 | if(Info.UserType != 3)BtnEdit.Enabled = true; 41 | } 42 | 43 | private void DGVBanks_CellClick(object sender, DataGridViewCellEventArgs e) 44 | { 45 | if (DGVBanks.SelectedRows.Count > 0) 46 | { 47 | TxtBankId.Text = DGVBanks.SelectedRows[0].Cells[0].Value + string.Empty; 48 | TxtBankName.Text = DGVBanks.SelectedRows[0].Cells[1].Value + string.Empty; 49 | if(Info.UserType != 3)BtnDelete.Enabled = true; 50 | } 51 | } 52 | 53 | private void ManageBanks_Load(object sender, EventArgs e) 54 | { 55 | DGVLoad(); 56 | } 57 | 58 | private void DGVLoad() 59 | { 60 | CRUDPanel.Enabled = false; 61 | BtnDelete.Enabled = false; 62 | BtnSave.Enabled = false; 63 | BtnCancel.Enabled = false; 64 | BtnAdd.Enabled = true; 65 | if(Info.UserType != 3) 66 | BtnEdit.Enabled = true; 67 | using (BillingContext db = new BillingContext()) 68 | { 69 | var data = (from bank in db.Banks.Where(c => !c.IsDeleted) 70 | select new 71 | { 72 | bank.BankId, 73 | bank.BankName 74 | }).ToList(); 75 | DGVBanks.DataSource = data; 76 | } 77 | } 78 | 79 | private void BtnSave_Click(object sender, EventArgs e) 80 | { 81 | Save(); 82 | } 83 | 84 | private void Save() 85 | { 86 | try 87 | { 88 | using (BillingContext db = new BillingContext()) 89 | { 90 | if (TxtBankId.Text.Length > 0) 91 | { 92 | if (TxtBankId.Text == "0" && Info.IsEmpty(TxtBankName)) 93 | { 94 | Bank b = new Bank 95 | { 96 | BankName = TxtBankName.Text.Trim() 97 | }; 98 | if (db.Entry(b).State == EntityState.Detached) 99 | db.Set().Attach(b); 100 | db.Entry(b).State = EntityState.Added; 101 | db.SaveChanges(); 102 | TxtBankName.Text = string.Empty; 103 | } 104 | else if (Info.IsEmpty(TxtBankName) && Info.IsEmpty(TxtBankId) && TxtBankId.Text.Trim() != "0") 105 | { 106 | var b = db.Banks.FirstOrDefault(c => c.BankId == Convert.ToInt32(TxtBankId.Text.Trim()) && !c.IsDeleted); 107 | if (b != null) 108 | { 109 | b.BankName = TxtBankName.Text.Trim(); 110 | if (db.Entry(b).State == EntityState.Detached) 111 | db.Set().Attach(b); 112 | db.Entry(b).State = EntityState.Modified; 113 | db.SaveChanges(); 114 | } 115 | } 116 | } 117 | } 118 | } 119 | catch (Exception ex) 120 | { 121 | ExportJson.Add(ex); Info.Mes(ex.Message); 122 | } 123 | finally 124 | { 125 | DGVLoad(); 126 | BtnSave.Enabled = false; 127 | BtnCancel.Enabled = false; 128 | } 129 | } 130 | 131 | private void BtnDelete_Click(object sender, EventArgs e) 132 | { 133 | try 134 | { 135 | int BankId = Convert.ToInt32(TxtBankId.Text.Trim()); 136 | using (BillingContext db = new BillingContext()) 137 | { 138 | if (DGVBanks.SelectedRows.Count > 0) 139 | { 140 | DialogResult dialogResult = MessageBox.Show("Are you sure you want to delete the selected Bank?", "Confirmation delete", MessageBoxButtons.YesNo); 141 | if (dialogResult == DialogResult.Yes && Info.IsEmpty(TxtBankId) && TxtBankId.Text.Trim() != "0") 142 | { 143 | var b = db.Banks.FirstOrDefault(c => c.BankId == BankId && !c.IsDeleted); 144 | if (b != null) 145 | { 146 | b.IsDeleted = true; 147 | if (db.Entry(b).State == EntityState.Detached) 148 | db.Set().Attach(b); 149 | db.Entry(b).State = EntityState.Modified; 150 | db.SaveChanges(); 151 | } 152 | } 153 | } 154 | } 155 | } 156 | catch (Exception ex) 157 | { 158 | ExportJson.Add(ex); Info.Mes(ex.Message); 159 | } 160 | finally 161 | { 162 | DGVLoad(); 163 | BtnSave.Enabled = false; 164 | BtnCancel.Enabled = false; 165 | } 166 | } 167 | 168 | private void TxtBankName_KeyDown(object sender, KeyEventArgs e) 169 | { 170 | if (e.KeyCode == Keys.Enter) 171 | { 172 | Save(); 173 | } 174 | } 175 | 176 | private void TxtBankName_KeyUp(object sender, KeyEventArgs e) 177 | { 178 | Info.ToCapital(TxtBankName); 179 | } 180 | } 181 | } -------------------------------------------------------------------------------- /SimpleBilling/MasterForms/CustomerLookUp.Designer.cs: -------------------------------------------------------------------------------- 1 | namespace SimpleBilling.MasterForms 2 | { 3 | partial class CustomerLookUp 4 | { 5 | /// 6 | /// Required designer variable. 7 | /// 8 | private System.ComponentModel.IContainer components = null; 9 | 10 | /// 11 | /// Clean up any resources being used. 12 | /// 13 | /// true if managed resources should be disposed; otherwise, false. 14 | protected override void Dispose(bool disposing) 15 | { 16 | if (disposing && (components != null)) 17 | { 18 | components.Dispose(); 19 | } 20 | base.Dispose(disposing); 21 | } 22 | 23 | #region Windows Form Designer generated code 24 | 25 | /// 26 | /// Required method for Designer support - do not modify 27 | /// the contents of this method with the code editor. 28 | /// 29 | private void InitializeComponent() 30 | { 31 | System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(CustomerLookUp)); 32 | this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel(); 33 | this.DGVCustomers = new System.Windows.Forms.DataGridView(); 34 | this.TxtSearchCustomers = new System.Windows.Forms.TextBox(); 35 | this.BtnOk = new System.Windows.Forms.Button(); 36 | this.tableLayoutPanel1.SuspendLayout(); 37 | ((System.ComponentModel.ISupportInitialize)(this.DGVCustomers)).BeginInit(); 38 | this.SuspendLayout(); 39 | // 40 | // tableLayoutPanel1 41 | // 42 | this.tableLayoutPanel1.ColumnCount = 1; 43 | this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F)); 44 | this.tableLayoutPanel1.Controls.Add(this.DGVCustomers, 0, 1); 45 | this.tableLayoutPanel1.Controls.Add(this.TxtSearchCustomers, 0, 0); 46 | this.tableLayoutPanel1.Controls.Add(this.BtnOk, 0, 2); 47 | this.tableLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Fill; 48 | this.tableLayoutPanel1.Location = new System.Drawing.Point(0, 0); 49 | this.tableLayoutPanel1.Name = "tableLayoutPanel1"; 50 | this.tableLayoutPanel1.RowCount = 3; 51 | this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 7F)); 52 | this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 86F)); 53 | this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 7F)); 54 | this.tableLayoutPanel1.Size = new System.Drawing.Size(641, 468); 55 | this.tableLayoutPanel1.TabIndex = 0; 56 | // 57 | // DGVCustomers 58 | // 59 | this.DGVCustomers.AllowUserToAddRows = false; 60 | this.DGVCustomers.AllowUserToDeleteRows = false; 61 | this.DGVCustomers.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.AllCells; 62 | this.DGVCustomers.AutoSizeRowsMode = System.Windows.Forms.DataGridViewAutoSizeRowsMode.AllCells; 63 | this.DGVCustomers.BackgroundColor = System.Drawing.Color.DimGray; 64 | this.DGVCustomers.BorderStyle = System.Windows.Forms.BorderStyle.None; 65 | this.DGVCustomers.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; 66 | this.DGVCustomers.Dock = System.Windows.Forms.DockStyle.Fill; 67 | this.DGVCustomers.Location = new System.Drawing.Point(3, 35); 68 | this.DGVCustomers.Name = "DGVCustomers"; 69 | this.DGVCustomers.ReadOnly = true; 70 | this.DGVCustomers.Size = new System.Drawing.Size(635, 396); 71 | this.DGVCustomers.TabIndex = 0; 72 | this.DGVCustomers.CellClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.DGVCustomers_CellClick); 73 | // 74 | // TxtSearchCustomers 75 | // 76 | this.TxtSearchCustomers.Dock = System.Windows.Forms.DockStyle.Fill; 77 | this.TxtSearchCustomers.Location = new System.Drawing.Point(3, 3); 78 | this.TxtSearchCustomers.Name = "TxtSearchCustomers"; 79 | this.TxtSearchCustomers.Size = new System.Drawing.Size(635, 22); 80 | this.TxtSearchCustomers.TabIndex = 1; 81 | this.TxtSearchCustomers.KeyUp += new System.Windows.Forms.KeyEventHandler(this.TxtSearchCustomers_KeyUp); 82 | // 83 | // BtnOk 84 | // 85 | this.BtnOk.BackColor = System.Drawing.Color.White; 86 | this.BtnOk.DialogResult = System.Windows.Forms.DialogResult.OK; 87 | this.BtnOk.Dock = System.Windows.Forms.DockStyle.Right; 88 | this.BtnOk.Location = new System.Drawing.Point(509, 437); 89 | this.BtnOk.Name = "BtnOk"; 90 | this.BtnOk.Size = new System.Drawing.Size(129, 28); 91 | this.BtnOk.TabIndex = 2; 92 | this.BtnOk.Text = "Ok"; 93 | this.BtnOk.UseVisualStyleBackColor = false; 94 | this.BtnOk.Click += new System.EventHandler(this.BtnOk_Click); 95 | // 96 | // CustomerLookUp 97 | // 98 | this.AcceptButton = this.BtnOk; 99 | this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F); 100 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 101 | this.BackColor = System.Drawing.Color.DimGray; 102 | this.ClientSize = new System.Drawing.Size(641, 468); 103 | this.Controls.Add(this.tableLayoutPanel1); 104 | this.Font = new System.Drawing.Font("Arial", 9.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); 105 | this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; 106 | this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); 107 | this.Margin = new System.Windows.Forms.Padding(4); 108 | this.MaximizeBox = false; 109 | this.Name = "CustomerLookUp"; 110 | this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; 111 | this.Text = "CustomerLookUp"; 112 | this.Load += new System.EventHandler(this.CustomerLookUp_Load); 113 | this.tableLayoutPanel1.ResumeLayout(false); 114 | this.tableLayoutPanel1.PerformLayout(); 115 | ((System.ComponentModel.ISupportInitialize)(this.DGVCustomers)).EndInit(); 116 | this.ResumeLayout(false); 117 | 118 | } 119 | 120 | #endregion 121 | 122 | private System.Windows.Forms.TableLayoutPanel tableLayoutPanel1; 123 | private System.Windows.Forms.DataGridView DGVCustomers; 124 | private System.Windows.Forms.TextBox TxtSearchCustomers; 125 | private System.Windows.Forms.Button BtnOk; 126 | } 127 | } -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | ## 4 | ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore 5 | 6 | # User-specific files 7 | *.rsuser 8 | *.suo 9 | *.user 10 | *.userosscache 11 | *.sln.docstates 12 | 13 | # User-specific files (MonoDevelop/Xamarin Studio) 14 | *.userprefs 15 | 16 | # Build results 17 | [Dd]ebug/ 18 | [Dd]ebugPublic/ 19 | [Rr]elease/ 20 | [Rr]eleases/ 21 | x64/ 22 | x86/ 23 | [Aa][Rr][Mm]/ 24 | [Aa][Rr][Mm]64/ 25 | bld/ 26 | [Bb]in/ 27 | [Oo]bj/ 28 | [Ll]og/ 29 | 30 | # Visual Studio 2015/2017 cache/options directory 31 | .vs/ 32 | # Uncomment if you have tasks that create the project's static files in wwwroot 33 | #wwwroot/ 34 | 35 | # Visual Studio 2017 auto generated files 36 | Generated\ Files/ 37 | 38 | # MSTest test Results 39 | [Tt]est[Rr]esult*/ 40 | [Bb]uild[Ll]og.* 41 | 42 | # NUNIT 43 | *.VisualState.xml 44 | TestResult.xml 45 | 46 | # Build Results of an ATL Project 47 | [Dd]ebugPS/ 48 | [Rr]eleasePS/ 49 | dlldata.c 50 | 51 | # Benchmark Results 52 | BenchmarkDotNet.Artifacts/ 53 | 54 | # .NET Core 55 | project.lock.json 56 | project.fragment.lock.json 57 | artifacts/ 58 | 59 | # StyleCop 60 | StyleCopReport.xml 61 | 62 | # Files built by Visual Studio 63 | *_i.c 64 | *_p.c 65 | *_h.h 66 | *.ilk 67 | *.meta 68 | *.obj 69 | *.iobj 70 | *.pch 71 | *.pdb 72 | *.ipdb 73 | *.pgc 74 | *.pgd 75 | *.rsp 76 | *.sbr 77 | *.tlb 78 | *.tli 79 | *.tlh 80 | *.tmp 81 | *.tmp_proj 82 | *_wpftmp.csproj 83 | *.log 84 | *.vspscc 85 | *.vssscc 86 | .builds 87 | *.pidb 88 | *.svclog 89 | *.scc 90 | 91 | # Chutzpah Test files 92 | _Chutzpah* 93 | 94 | # Visual C++ cache files 95 | ipch/ 96 | *.aps 97 | *.ncb 98 | *.opendb 99 | *.opensdf 100 | *.sdf 101 | *.cachefile 102 | *.VC.db 103 | *.VC.VC.opendb 104 | 105 | # Visual Studio profiler 106 | *.psess 107 | *.vsp 108 | *.vspx 109 | *.sap 110 | 111 | # Visual Studio Trace Files 112 | *.e2e 113 | 114 | # TFS 2012 Local Workspace 115 | $tf/ 116 | 117 | # Guidance Automation Toolkit 118 | *.gpState 119 | 120 | # ReSharper is a .NET coding add-in 121 | _ReSharper*/ 122 | *.[Rr]e[Ss]harper 123 | *.DotSettings.user 124 | 125 | # JustCode is a .NET coding add-in 126 | .JustCode 127 | 128 | # TeamCity is a build add-in 129 | _TeamCity* 130 | 131 | # DotCover is a Code Coverage Tool 132 | *.dotCover 133 | 134 | # AxoCover is a Code Coverage Tool 135 | .axoCover/* 136 | !.axoCover/settings.json 137 | 138 | # Visual Studio code coverage results 139 | *.coverage 140 | *.coveragexml 141 | 142 | # NCrunch 143 | _NCrunch_* 144 | .*crunch*.local.xml 145 | nCrunchTemp_* 146 | 147 | # MightyMoose 148 | *.mm.* 149 | AutoTest.Net/ 150 | 151 | # Web workbench (sass) 152 | .sass-cache/ 153 | 154 | # Installshield output folder 155 | [Ee]xpress/ 156 | 157 | # DocProject is a documentation generator add-in 158 | DocProject/buildhelp/ 159 | DocProject/Help/*.HxT 160 | DocProject/Help/*.HxC 161 | DocProject/Help/*.hhc 162 | DocProject/Help/*.hhk 163 | DocProject/Help/*.hhp 164 | DocProject/Help/Html2 165 | DocProject/Help/html 166 | 167 | # Click-Once directory 168 | publish/ 169 | 170 | # Publish Web Output 171 | *.[Pp]ublish.xml 172 | *.azurePubxml 173 | # Note: Comment the next line if you want to checkin your web deploy settings, 174 | # but database connection strings (with potential passwords) will be unencrypted 175 | *.pubxml 176 | *.publishproj 177 | 178 | # Microsoft Azure Web App publish settings. Comment the next line if you want to 179 | # checkin your Azure Web App publish settings, but sensitive information contained 180 | # in these scripts will be unencrypted 181 | PublishScripts/ 182 | 183 | # NuGet Packages 184 | *.nupkg 185 | # The packages folder can be ignored because of Package Restore 186 | **/[Pp]ackages/* 187 | # except build/, which is used as an MSBuild target. 188 | !**/[Pp]ackages/build/ 189 | # Uncomment if necessary however generally it will be regenerated when needed 190 | #!**/[Pp]ackages/repositories.config 191 | # NuGet v3's project.json files produces more ignorable files 192 | *.nuget.props 193 | *.nuget.targets 194 | 195 | # Microsoft Azure Build Output 196 | csx/ 197 | *.build.csdef 198 | 199 | # Microsoft Azure Emulator 200 | ecf/ 201 | rcf/ 202 | 203 | # Windows Store app package directories and files 204 | AppPackages/ 205 | BundleArtifacts/ 206 | Package.StoreAssociation.xml 207 | _pkginfo.txt 208 | *.appx 209 | 210 | # Visual Studio cache files 211 | # files ending in .cache can be ignored 212 | *.[Cc]ache 213 | # but keep track of directories ending in .cache 214 | !?*.[Cc]ache/ 215 | 216 | # Others 217 | ClientBin/ 218 | ~$* 219 | *~ 220 | *.dbmdl 221 | *.dbproj.schemaview 222 | *.jfm 223 | *.pfx 224 | *.publishsettings 225 | orleans.codegen.cs 226 | 227 | # Including strong name files can present a security risk 228 | # (https://github.com/github/gitignore/pull/2483#issue-259490424) 229 | #*.snk 230 | 231 | # Since there are multiple workflows, uncomment next line to ignore bower_components 232 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) 233 | #bower_components/ 234 | 235 | # RIA/Silverlight projects 236 | Generated_Code/ 237 | 238 | # Backup & report files from converting an old project file 239 | # to a newer Visual Studio version. Backup files are not needed, 240 | # because we have git ;-) 241 | _UpgradeReport_Files/ 242 | Backup*/ 243 | UpgradeLog*.XML 244 | UpgradeLog*.htm 245 | ServiceFabricBackup/ 246 | *.rptproj.bak 247 | 248 | # SQL Server files 249 | *.mdf 250 | *.ldf 251 | *.ndf 252 | 253 | # Business Intelligence projects 254 | *.rdl.data 255 | *.bim.layout 256 | *.bim_*.settings 257 | *.rptproj.rsuser 258 | *- Backup*.rdl 259 | 260 | # Microsoft Fakes 261 | FakesAssemblies/ 262 | 263 | # GhostDoc plugin setting file 264 | *.GhostDoc.xml 265 | 266 | # Node.js Tools for Visual Studio 267 | .ntvs_analysis.dat 268 | node_modules/ 269 | 270 | # Visual Studio 6 build log 271 | *.plg 272 | 273 | # Visual Studio 6 workspace options file 274 | *.opt 275 | 276 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.) 277 | *.vbw 278 | 279 | # Visual Studio LightSwitch build output 280 | **/*.HTMLClient/GeneratedArtifacts 281 | **/*.DesktopClient/GeneratedArtifacts 282 | **/*.DesktopClient/ModelManifest.xml 283 | **/*.Server/GeneratedArtifacts 284 | **/*.Server/ModelManifest.xml 285 | _Pvt_Extensions 286 | 287 | # Paket dependency manager 288 | .paket/paket.exe 289 | paket-files/ 290 | 291 | # FAKE - F# Make 292 | .fake/ 293 | 294 | # JetBrains Rider 295 | .idea/ 296 | *.sln.iml 297 | 298 | # CodeRush personal settings 299 | .cr/personal 300 | 301 | # Python Tools for Visual Studio (PTVS) 302 | __pycache__/ 303 | *.pyc 304 | 305 | # Cake - Uncomment if you are using it 306 | # tools/** 307 | # !tools/packages.config 308 | 309 | # Tabs Studio 310 | *.tss 311 | 312 | # Telerik's JustMock configuration file 313 | *.jmconfig 314 | 315 | # BizTalk build output 316 | *.btp.cs 317 | *.btm.cs 318 | *.odx.cs 319 | *.xsd.cs 320 | 321 | # OpenCover UI analysis results 322 | OpenCover/ 323 | 324 | # Azure Stream Analytics local run output 325 | ASALocalRun/ 326 | 327 | # MSBuild Binary and Structured Log 328 | *.binlog 329 | 330 | # NVidia Nsight GPU debugger configuration file 331 | *.nvuser 332 | 333 | # MFractors (Xamarin productivity tool) working folder 334 | .mfractor/ 335 | 336 | # Local History for Visual Studio 337 | .localhistory/ 338 | 339 | # BeatPulse healthcheck temp database 340 | healthchecksdb -------------------------------------------------------------------------------- /SimpleBilling/MasterForms/ItemLookup.Designer.cs: -------------------------------------------------------------------------------- 1 | namespace SimpleBilling.MasterForms 2 | { 3 | partial class ItemLookup 4 | { 5 | /// 6 | /// Required designer variable. 7 | /// 8 | private System.ComponentModel.IContainer components = null; 9 | 10 | /// 11 | /// Clean up any resources being used. 12 | /// 13 | /// true if managed resources should be disposed; otherwise, false. 14 | protected override void Dispose(bool disposing) 15 | { 16 | if (disposing && (components != null)) 17 | { 18 | components.Dispose(); 19 | } 20 | base.Dispose(disposing); 21 | } 22 | 23 | #region Windows Form Designer generated code 24 | 25 | /// 26 | /// Required method for Designer support - do not modify 27 | /// the contents of this method with the code editor. 28 | /// 29 | private void InitializeComponent() 30 | { 31 | System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(ItemLookup)); 32 | this.DGVItems = new System.Windows.Forms.DataGridView(); 33 | this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel(); 34 | this.TxtItemLookUp = new System.Windows.Forms.TextBox(); 35 | this.BtnOk = new System.Windows.Forms.Button(); 36 | ((System.ComponentModel.ISupportInitialize)(this.DGVItems)).BeginInit(); 37 | this.tableLayoutPanel1.SuspendLayout(); 38 | this.SuspendLayout(); 39 | // 40 | // DGVItems 41 | // 42 | this.DGVItems.AllowUserToAddRows = false; 43 | this.DGVItems.AllowUserToDeleteRows = false; 44 | this.DGVItems.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.AllCells; 45 | this.DGVItems.AutoSizeRowsMode = System.Windows.Forms.DataGridViewAutoSizeRowsMode.AllCells; 46 | this.DGVItems.BackgroundColor = System.Drawing.Color.DimGray; 47 | this.DGVItems.BorderStyle = System.Windows.Forms.BorderStyle.None; 48 | this.DGVItems.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; 49 | this.DGVItems.Dock = System.Windows.Forms.DockStyle.Fill; 50 | this.DGVItems.Location = new System.Drawing.Point(3, 36); 51 | this.DGVItems.Name = "DGVItems"; 52 | this.DGVItems.ReadOnly = true; 53 | this.DGVItems.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect; 54 | this.DGVItems.Size = new System.Drawing.Size(794, 400); 55 | this.DGVItems.TabIndex = 0; 56 | this.DGVItems.CellClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.DGVItems_CellClick); 57 | this.DGVItems.CellDoubleClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.DGVItems_CellDoubleClick); 58 | this.DGVItems.MouseClick += new System.Windows.Forms.MouseEventHandler(this.DGVItems_MouseClick); 59 | // 60 | // tableLayoutPanel1 61 | // 62 | this.tableLayoutPanel1.ColumnCount = 1; 63 | this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F)); 64 | this.tableLayoutPanel1.Controls.Add(this.DGVItems, 0, 1); 65 | this.tableLayoutPanel1.Controls.Add(this.TxtItemLookUp, 0, 0); 66 | this.tableLayoutPanel1.Controls.Add(this.BtnOk, 0, 2); 67 | this.tableLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Fill; 68 | this.tableLayoutPanel1.Location = new System.Drawing.Point(0, 0); 69 | this.tableLayoutPanel1.Name = "tableLayoutPanel1"; 70 | this.tableLayoutPanel1.RowCount = 3; 71 | this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 7F)); 72 | this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 86F)); 73 | this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 7F)); 74 | this.tableLayoutPanel1.Size = new System.Drawing.Size(800, 473); 75 | this.tableLayoutPanel1.TabIndex = 1; 76 | // 77 | // TxtItemLookUp 78 | // 79 | this.TxtItemLookUp.Dock = System.Windows.Forms.DockStyle.Fill; 80 | this.TxtItemLookUp.Location = new System.Drawing.Point(3, 3); 81 | this.TxtItemLookUp.Name = "TxtItemLookUp"; 82 | this.TxtItemLookUp.Size = new System.Drawing.Size(794, 26); 83 | this.TxtItemLookUp.TabIndex = 1; 84 | this.TxtItemLookUp.KeyUp += new System.Windows.Forms.KeyEventHandler(this.TxtItemLookUp_KeyUp); 85 | // 86 | // BtnOk 87 | // 88 | this.BtnOk.DialogResult = System.Windows.Forms.DialogResult.OK; 89 | this.BtnOk.Dock = System.Windows.Forms.DockStyle.Right; 90 | this.BtnOk.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); 91 | this.BtnOk.Location = new System.Drawing.Point(665, 442); 92 | this.BtnOk.Name = "BtnOk"; 93 | this.BtnOk.Size = new System.Drawing.Size(132, 28); 94 | this.BtnOk.TabIndex = 2; 95 | this.BtnOk.Text = "Ok"; 96 | this.BtnOk.UseVisualStyleBackColor = true; 97 | this.BtnOk.Click += new System.EventHandler(this.BtnOk_Click); 98 | // 99 | // ItemLookup 100 | // 101 | this.AcceptButton = this.BtnOk; 102 | this.AutoScaleDimensions = new System.Drawing.SizeF(10F, 20F); 103 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 104 | this.BackColor = System.Drawing.Color.DimGray; 105 | this.ClientSize = new System.Drawing.Size(800, 473); 106 | this.Controls.Add(this.tableLayoutPanel1); 107 | this.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); 108 | this.ForeColor = System.Drawing.Color.Black; 109 | this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; 110 | this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); 111 | this.Margin = new System.Windows.Forms.Padding(5); 112 | this.Name = "ItemLookup"; 113 | this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; 114 | this.Text = "ItemLookup"; 115 | this.Load += new System.EventHandler(this.ItemLookup_Load); 116 | ((System.ComponentModel.ISupportInitialize)(this.DGVItems)).EndInit(); 117 | this.tableLayoutPanel1.ResumeLayout(false); 118 | this.tableLayoutPanel1.PerformLayout(); 119 | this.ResumeLayout(false); 120 | 121 | } 122 | 123 | #endregion 124 | 125 | private System.Windows.Forms.DataGridView DGVItems; 126 | private System.Windows.Forms.TableLayoutPanel tableLayoutPanel1; 127 | private System.Windows.Forms.TextBox TxtItemLookUp; 128 | private System.Windows.Forms.Button BtnOk; 129 | } 130 | } -------------------------------------------------------------------------------- /SimpleBilling/MasterForms/ManageEmployees.cs: -------------------------------------------------------------------------------- 1 | using SimpleBilling.Model; 2 | using System; 3 | using System.Data.Entity; 4 | using System.Linq; 5 | using System.Windows.Forms; 6 | 7 | namespace SimpleBilling.MasterForms 8 | { 9 | public partial class ManageEmployees : Form 10 | { 11 | public ManageEmployees() 12 | { 13 | InitializeComponent(); 14 | } 15 | 16 | private void ManageEmployees_Load(object sender, EventArgs e) 17 | { 18 | CRUDPanel.Enabled = false; 19 | LoadDGV(string.Empty); 20 | } 21 | 22 | private void LoadDGV(string Input) 23 | { 24 | using (BillingContext db = new BillingContext()) 25 | { 26 | if (string.IsNullOrWhiteSpace(Input)) 27 | { 28 | var data = (from emp in db.Employee.Where(c => !c.IsDeleted) 29 | select new 30 | { 31 | emp.EmployeeId, 32 | emp.EmployeeName, 33 | emp.Contact, 34 | emp.Address, 35 | emp.Email 36 | }).ToList(); 37 | DGVEmployees.DataSource = data; 38 | } 39 | else 40 | { 41 | var data = (from emp in db.Employee.Where(c => !c.IsDeleted) 42 | select new 43 | { 44 | emp.EmployeeId, 45 | emp.EmployeeName, 46 | emp.Contact, 47 | emp.Address, 48 | emp.Email 49 | }).Where(a=>a.EmployeeName.Contains(Input) || a.Contact.Contains(Input) || a.Address.Contains(Input) || a.Email.Contains(Input)).ToList(); 50 | DGVEmployees.DataSource = data; 51 | } 52 | } 53 | } 54 | 55 | private void BtnAdd_Click(object sender, EventArgs e) 56 | { 57 | CRUDPanel.Enabled = true; 58 | BtnSave.Enabled = true; 59 | employeeBindingSource1.Add(new Employee()); 60 | employeeBindingSource1.MoveLast(); 61 | TxtEmployeeName.Focus(); 62 | } 63 | 64 | private void BtnEdit_Click(object sender, EventArgs e) 65 | { 66 | CRUDPanel.Enabled = true; 67 | BtnSave.Enabled = true; 68 | TxtEmployeeName.Focus(); 69 | _ = employeeBindingSource1.Current as Employee; 70 | } 71 | 72 | private void BtnDelete_Click(object sender, EventArgs e) 73 | { 74 | try 75 | { 76 | DialogResult dialogResult = MessageBox.Show("Are you sure you want to delete the selected Item?", "Confirmation delete", MessageBoxButtons.YesNo); 77 | if (dialogResult == DialogResult.Yes) 78 | { 79 | using (BillingContext db = new BillingContext()) 80 | { 81 | if (employeeBindingSource1.Current is Employee emp) 82 | { 83 | if (db.Entry(emp).State == EntityState.Detached) 84 | db.Set().Attach(emp); 85 | emp.IsDeleted = true; 86 | emp.UpdatedDate = DateTime.Now; 87 | db.Entry(emp).State = EntityState.Modified; 88 | emp.UpdatedDate = DateTime.Now; 89 | db.SaveChanges(); 90 | Message("Employee Deleted Successfully"); 91 | } 92 | } 93 | } 94 | } 95 | catch (Exception ex) 96 | { 97 | ExportJson.Add(ex); 98 | Message(ex.ToString()); 99 | } 100 | finally 101 | { 102 | DGVEmployees.Refresh(); 103 | LoadDGV(string.Empty); 104 | } 105 | } 106 | 107 | private void Message(string Message) 108 | { 109 | Info.Mes(Message); 110 | } 111 | 112 | private void BtnCancel_Click(object sender, EventArgs e) 113 | { 114 | CRUDPanel.Enabled = false; 115 | } 116 | 117 | private void BtnSave_Click(object sender, EventArgs e) 118 | { 119 | try 120 | { 121 | using (BillingContext db = new BillingContext()) 122 | { 123 | if (employeeBindingSource1.Current is Employee emp) 124 | { 125 | if (db.Entry(emp).State == EntityState.Detached) 126 | db.Set().Attach(emp); 127 | if (emp.EmployeeId == 0) 128 | { 129 | db.Entry(emp).State = EntityState.Added; 130 | emp.CreatedDate = DateTime.Now; 131 | Message("Employee Added"); 132 | } 133 | else 134 | { 135 | db.Entry(emp).State = EntityState.Modified; 136 | emp.UpdatedDate = DateTime.Now; 137 | Message("Employee Modified"); 138 | } 139 | db.SaveChanges(); 140 | } 141 | } 142 | } 143 | catch (Exception ex) 144 | { 145 | ExportJson.Add(ex); 146 | Message(ex.ToString()); 147 | } 148 | finally 149 | { 150 | DGVEmployees.Refresh(); 151 | LoadDGV(string.Empty); 152 | } 153 | } 154 | 155 | private void TxtEmployeeName_KeyUp(object sender, KeyEventArgs e) 156 | { 157 | Info.ToCapital(TxtEmployeeName); 158 | } 159 | 160 | private void TxtAddress_KeyUp(object sender, KeyEventArgs e) 161 | { 162 | Info.ToCapital(TxtAddress); 163 | } 164 | 165 | private void TxtSearchEmployees_KeyUp(object sender, KeyEventArgs e) 166 | { 167 | Info.ToCapital(TxtSearchEmployees); 168 | LoadDGV(TxtSearchEmployees.Text.Trim()); 169 | } 170 | 171 | private void DGVEmployees_CellClick(object sender, DataGridViewCellEventArgs e) 172 | { 173 | if (DGVEmployees.SelectedRows.Count > 0) 174 | { 175 | TxtEmployeeId.Text = DGVEmployees.SelectedRows[0].Cells[0].Value + string.Empty; 176 | TxtEmployeeName.Text = DGVEmployees.SelectedRows[0].Cells[1].Value + string.Empty; 177 | TxtContact.Text = DGVEmployees.SelectedRows[0].Cells[2].Value + string.Empty; 178 | TxtAddress.Text = DGVEmployees.SelectedRows[0].Cells[3].Value + string.Empty; 179 | TxtEmail.Text = DGVEmployees.SelectedRows[0].Cells[4].Value + string.Empty; 180 | using (BillingContext db = new BillingContext()) 181 | { 182 | int EmpId = Convert.ToInt32(DGVEmployees.SelectedRows[0].Cells[0].Value + string.Empty); 183 | var emp = db.Employee.FirstOrDefault(c => c.EmployeeId == EmpId && !c.IsDeleted); 184 | TxtSecretCode.Text = emp.SecretCode; 185 | } 186 | } 187 | } 188 | } 189 | } -------------------------------------------------------------------------------- /SimpleBilling/Reports/VoidedReceipts.Designer.cs: -------------------------------------------------------------------------------- 1 | namespace SimpleBilling.Reports 2 | { 3 | partial class VoidedReceipts 4 | { 5 | /// 6 | /// Required designer variable. 7 | /// 8 | private System.ComponentModel.IContainer components = null; 9 | 10 | /// 11 | /// Clean up any resources being used. 12 | /// 13 | /// true if managed resources should be disposed; otherwise, false. 14 | protected override void Dispose(bool disposing) 15 | { 16 | if (disposing && (components != null)) 17 | { 18 | components.Dispose(); 19 | } 20 | base.Dispose(disposing); 21 | } 22 | 23 | #region Windows Form Designer generated code 24 | 25 | /// 26 | /// Required method for Designer support - do not modify 27 | /// the contents of this method with the code editor. 28 | /// 29 | private void InitializeComponent() 30 | { 31 | System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(VoidedReceipts)); 32 | this.BaseLayout = new System.Windows.Forms.TableLayoutPanel(); 33 | this.DGVReport = new System.Windows.Forms.DataGridView(); 34 | this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel(); 35 | this.DTPTo = new System.Windows.Forms.DateTimePicker(); 36 | this.DTPFrom = new System.Windows.Forms.DateTimePicker(); 37 | this.BtnFilter = new System.Windows.Forms.Button(); 38 | this.BaseLayout.SuspendLayout(); 39 | ((System.ComponentModel.ISupportInitialize)(this.DGVReport)).BeginInit(); 40 | this.tableLayoutPanel1.SuspendLayout(); 41 | this.SuspendLayout(); 42 | // 43 | // BaseLayout 44 | // 45 | this.BaseLayout.BackColor = System.Drawing.Color.DimGray; 46 | this.BaseLayout.ColumnCount = 1; 47 | this.BaseLayout.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F)); 48 | this.BaseLayout.Controls.Add(this.DGVReport, 0, 1); 49 | this.BaseLayout.Controls.Add(this.tableLayoutPanel1, 0, 0); 50 | this.BaseLayout.Dock = System.Windows.Forms.DockStyle.Fill; 51 | this.BaseLayout.Location = new System.Drawing.Point(0, 0); 52 | this.BaseLayout.Name = "BaseLayout"; 53 | this.BaseLayout.RowCount = 3; 54 | this.BaseLayout.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 8.067437F)); 55 | this.BaseLayout.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 84.86083F)); 56 | this.BaseLayout.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 7.071736F)); 57 | this.BaseLayout.Size = new System.Drawing.Size(833, 465); 58 | this.BaseLayout.TabIndex = 0; 59 | // 60 | // DGVReport 61 | // 62 | this.DGVReport.AllowUserToAddRows = false; 63 | this.DGVReport.AllowUserToDeleteRows = false; 64 | this.DGVReport.BackgroundColor = System.Drawing.Color.DimGray; 65 | this.DGVReport.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; 66 | this.DGVReport.Dock = System.Windows.Forms.DockStyle.Fill; 67 | this.DGVReport.Location = new System.Drawing.Point(3, 40); 68 | this.DGVReport.Name = "DGVReport"; 69 | this.DGVReport.ReadOnly = true; 70 | this.DGVReport.Size = new System.Drawing.Size(827, 388); 71 | this.DGVReport.TabIndex = 0; 72 | // 73 | // tableLayoutPanel1 74 | // 75 | this.tableLayoutPanel1.ColumnCount = 3; 76 | this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 33.33333F)); 77 | this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 33.33333F)); 78 | this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 33.33333F)); 79 | this.tableLayoutPanel1.Controls.Add(this.DTPTo, 1, 0); 80 | this.tableLayoutPanel1.Controls.Add(this.DTPFrom, 0, 0); 81 | this.tableLayoutPanel1.Controls.Add(this.BtnFilter, 2, 0); 82 | this.tableLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Fill; 83 | this.tableLayoutPanel1.Location = new System.Drawing.Point(3, 3); 84 | this.tableLayoutPanel1.Name = "tableLayoutPanel1"; 85 | this.tableLayoutPanel1.RowCount = 1; 86 | this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F)); 87 | this.tableLayoutPanel1.Size = new System.Drawing.Size(827, 31); 88 | this.tableLayoutPanel1.TabIndex = 1; 89 | // 90 | // DTPTo 91 | // 92 | this.DTPTo.Dock = System.Windows.Forms.DockStyle.Fill; 93 | this.DTPTo.Format = System.Windows.Forms.DateTimePickerFormat.Short; 94 | this.DTPTo.Location = new System.Drawing.Point(278, 3); 95 | this.DTPTo.Name = "DTPTo"; 96 | this.DTPTo.Size = new System.Drawing.Size(269, 22); 97 | this.DTPTo.TabIndex = 1; 98 | // 99 | // DTPFrom 100 | // 101 | this.DTPFrom.Dock = System.Windows.Forms.DockStyle.Fill; 102 | this.DTPFrom.Format = System.Windows.Forms.DateTimePickerFormat.Short; 103 | this.DTPFrom.Location = new System.Drawing.Point(3, 3); 104 | this.DTPFrom.Name = "DTPFrom"; 105 | this.DTPFrom.Size = new System.Drawing.Size(269, 22); 106 | this.DTPFrom.TabIndex = 0; 107 | // 108 | // BtnFilter 109 | // 110 | this.BtnFilter.Dock = System.Windows.Forms.DockStyle.Fill; 111 | this.BtnFilter.Location = new System.Drawing.Point(553, 3); 112 | this.BtnFilter.Name = "BtnFilter"; 113 | this.BtnFilter.Size = new System.Drawing.Size(271, 25); 114 | this.BtnFilter.TabIndex = 2; 115 | this.BtnFilter.Text = "Filter"; 116 | this.BtnFilter.UseVisualStyleBackColor = true; 117 | // 118 | // VoidedReceipts 119 | // 120 | this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F); 121 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 122 | this.ClientSize = new System.Drawing.Size(833, 465); 123 | this.Controls.Add(this.BaseLayout); 124 | this.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); 125 | this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); 126 | this.Margin = new System.Windows.Forms.Padding(4); 127 | this.Name = "VoidedReceipts"; 128 | this.Text = "VoidedReceipts"; 129 | this.Load += new System.EventHandler(this.VoidedReceipts_Load); 130 | this.BaseLayout.ResumeLayout(false); 131 | ((System.ComponentModel.ISupportInitialize)(this.DGVReport)).EndInit(); 132 | this.tableLayoutPanel1.ResumeLayout(false); 133 | this.ResumeLayout(false); 134 | 135 | } 136 | 137 | #endregion 138 | 139 | private System.Windows.Forms.TableLayoutPanel BaseLayout; 140 | private System.Windows.Forms.DataGridView DGVReport; 141 | private System.Windows.Forms.TableLayoutPanel tableLayoutPanel1; 142 | private System.Windows.Forms.DateTimePicker DTPTo; 143 | private System.Windows.Forms.DateTimePicker DTPFrom; 144 | private System.Windows.Forms.Button BtnFilter; 145 | } 146 | } -------------------------------------------------------------------------------- /SimpleBilling/MasterForms/LoadReceipt.cs: -------------------------------------------------------------------------------- 1 | using SimpleBilling.Model; 2 | using System; 3 | using System.Data; 4 | using System.Linq; 5 | using System.Windows.Forms; 6 | 7 | namespace SimpleBilling.MasterForms 8 | { 9 | public partial class LoadReceipt : Form 10 | { 11 | private string ReceiptNo; 12 | private DataTable Rpt; 13 | 14 | public LoadReceipt() 15 | { 16 | InitializeComponent(); 17 | } 18 | 19 | private void LoadReceipt_Load(object sender, EventArgs e) 20 | { 21 | DGVLoad(); 22 | } 23 | 24 | private void DGVLoad() 25 | { 26 | using (BillingContext db = new BillingContext()) 27 | { 28 | var data = (from header in db.ReceiptHeaders.Where(c => !c.IsDeleted && !c.IsQuotation) 29 | join cashier in db.Employee 30 | on header.Cashier equals cashier.EmployeeId 31 | join cus in db.Customers 32 | on header.CustomerId equals cus.CustomerId 33 | select new 34 | { 35 | header.ReceiptNo, 36 | header.Date, 37 | header.Time, 38 | cashier.EmployeeName, 39 | cus.Name, 40 | header.SubTotal, 41 | header.TotalDiscount, 42 | header.NetTotal, 43 | header.PaymentType 44 | }).ToList(); 45 | DGVLoadReceipt.DataSource = data; 46 | Rpt = Info.ToDataTable(data); 47 | } 48 | } 49 | 50 | private void LoadReceiptFromDGV() 51 | { 52 | if (DGVLoadReceipt.SelectedRows.Count > 0) 53 | { 54 | ReceiptNo = DGVLoadReceipt.SelectedRows[0].Cells[0].Value + string.Empty; 55 | } 56 | } 57 | 58 | private void BtnLoadReceipt_Click(object sender, EventArgs e) 59 | { 60 | LoadReceiptFromDGV(); 61 | OpenOPS(); 62 | } 63 | 64 | private void OpenOPS() 65 | { 66 | try 67 | { 68 | if (DGVLoadReceipt.SelectedRows.Count > 0) 69 | { 70 | POS pos = new POS(ReceiptNo); 71 | pos.Show(); 72 | Hide(); 73 | } 74 | } 75 | catch (Exception ex) 76 | { 77 | ExportJson.Add(ex); 78 | } 79 | } 80 | 81 | private void DGVLoadReceipt_CellDoubleClick(object sender, DataGridViewCellEventArgs e) 82 | { 83 | LoadReceiptFromDGV(); 84 | OpenOPS(); 85 | } 86 | 87 | private void TxtFilterReceipts_KeyUp(object sender, KeyEventArgs e) 88 | { 89 | try 90 | { 91 | string FilterByReceipt = TxtFilterReceipts.Text.Trim(); 92 | using (BillingContext db = new BillingContext()) 93 | { 94 | if (FilterByReceipt.Length > 0) 95 | { 96 | var data = (from header in db.ReceiptHeaders.Where(c => !c.IsDeleted && !c.IsQuotation) 97 | join cashier in db.Employee 98 | on header.Cashier equals cashier.EmployeeId 99 | join cus in db.Customers 100 | on header.CustomerId equals cus.CustomerId 101 | select new 102 | { 103 | header.ReceiptNo, 104 | header.Date, 105 | header.Time, 106 | cashier.EmployeeName, 107 | cus.Name, 108 | header.SubTotal, 109 | header.TotalDiscount, 110 | header.NetTotal, 111 | header.PaymentType 112 | }).Where(c => c.ReceiptNo.Contains(FilterByReceipt) || c.Name.Contains(FilterByReceipt) 113 | || c.EmployeeName.Contains(FilterByReceipt) || c.PaymentType == FilterByReceipt).ToList(); 114 | DGVLoadReceipt.DataSource = data; 115 | } 116 | else 117 | { 118 | DGVLoad(); 119 | } 120 | } 121 | } 122 | catch (Exception ex) 123 | { 124 | ExportJson.Add(ex); Info.Mes(ex.Message); 125 | } 126 | } 127 | 128 | private void BtnGetTodaysReceipts_Click(object sender, EventArgs e) 129 | { 130 | try 131 | { 132 | using (BillingContext db = new BillingContext()) 133 | { 134 | string date = DateTime.Today.ToShortDateString(); 135 | if (date.Length > 0) 136 | { 137 | var data = (from header in db.ReceiptHeaders 138 | .Where(c => !c.IsDeleted && !c.IsQuotation 139 | && c.Date == date) 140 | join cashier in db.Employee 141 | on header.Cashier equals cashier.EmployeeId 142 | select new 143 | { 144 | header.ReceiptNo, 145 | header.Date, 146 | header.Time, 147 | cashier.EmployeeName, 148 | header.SubTotal, 149 | header.TotalDiscount, 150 | header.NetTotal, 151 | header.PaymentType 152 | }).ToList(); 153 | DGVLoadReceipt.DataSource = data; 154 | } 155 | } 156 | } 157 | catch (Exception ex) 158 | { 159 | ExportJson.Add(ex); Info.Mes(ex.Message); 160 | } 161 | } 162 | 163 | private void BtnViewAll_Click(object sender, EventArgs e) 164 | { 165 | using (BillingContext db = new BillingContext()) 166 | { 167 | var data = (from header in db.ReceiptHeaders 168 | .Where(c => !c.IsDeleted && !c.IsQuotation) 169 | join cashier in db.Employee 170 | on header.Cashier equals cashier.EmployeeId 171 | select new 172 | { 173 | header.ReceiptNo, 174 | header.Date, 175 | header.Time, 176 | cashier.EmployeeName, 177 | header.SubTotal, 178 | header.TotalDiscount, 179 | header.NetTotal, 180 | header.PaymentType 181 | }).ToList(); 182 | DGVLoadReceipt.DataSource = data; 183 | } 184 | } 185 | 186 | private void BtnExportAsExcel_Click(object sender, EventArgs e) 187 | { 188 | Info.ExportAsExcel(DGVLoadReceipt); 189 | } 190 | 191 | private void BtnExportAsPDF_Click(object sender, EventArgs e) 192 | { 193 | try 194 | { 195 | Info.ExportReceiptsAsPDF(Rpt); 196 | } 197 | catch (Exception ex) 198 | { 199 | ExportJson.Add(ex); Info.Mes(ex.Message); 200 | } 201 | } 202 | } 203 | } -------------------------------------------------------------------------------- /SimpleBilling/Migrations/202004221836553_billing5.resx: -------------------------------------------------------------------------------- 1 | 2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | text/microsoft-resx 110 | 111 | 112 | 2.0 113 | 114 | 115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | 118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 119 | 120 | 121 | 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 122 | 123 | 124 | dbo 125 | 126 | -------------------------------------------------------------------------------- /SimpleBilling/Migrations/202004221641345_billing3.resx: -------------------------------------------------------------------------------- 1 | 2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | text/microsoft-resx 110 | 111 | 112 | 2.0 113 | 114 | 115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | 118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 119 | 120 | 121 | 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 122 | 123 | 124 | dbo 125 | 126 | -------------------------------------------------------------------------------- /SimpleBilling/Migrations/202004221659462_billing4.resx: -------------------------------------------------------------------------------- 1 | 2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | text/microsoft-resx 110 | 111 | 112 | 2.0 113 | 114 | 115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | 118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 119 | 120 | 121 | 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 122 | 123 | 124 | dbo 125 | 126 | -------------------------------------------------------------------------------- /SimpleBilling/MasterForms/ManageCustomers.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.OData.Edm; 2 | using SimpleBilling.Model; 3 | using System; 4 | using System.Data.Entity; 5 | using System.Linq; 6 | using System.Windows.Forms; 7 | 8 | namespace SimpleBilling 9 | { 10 | public partial class ManageCustomers : Form 11 | { 12 | public ManageCustomers() 13 | { 14 | InitializeComponent(); 15 | } 16 | 17 | private void ManageCustomers_Load(object sender, EventArgs e) 18 | { 19 | LoadDGV(); 20 | } 21 | 22 | private void LoadDGV() 23 | { 24 | try 25 | { 26 | CRUDPanel.Enabled = false; 27 | BtnSave.Enabled = false; 28 | BtnCancel.Enabled = false; 29 | BtnDelete.Enabled = false; 30 | using (BillingContext db = new BillingContext()) 31 | { 32 | var data = db.Customers.Where(c => !c.IsDeleted).ToList(); 33 | DGVCustomers.DataSource = data; 34 | } 35 | } 36 | catch (Exception ex) 37 | { 38 | Info.Mes(ex.Message); 39 | } 40 | } 41 | 42 | private void Message(string Message) 43 | { 44 | Info.Mes(Message); 45 | } 46 | 47 | private void BtnCancel_Click(object sender, EventArgs e) 48 | { 49 | CRUDPanel.Enabled = false; 50 | BtnSave.Enabled = false; 51 | BtnCancel.Enabled = false; 52 | BtnDelete.Enabled = false; 53 | } 54 | 55 | private void BtnAdd_Click(object sender, EventArgs e) 56 | { 57 | CRUDPanel.Enabled = true; 58 | BtnSave.Enabled = true; 59 | BtnCancel.Enabled = true; 60 | customersBindingSource1.Add(new Customers()); 61 | customersBindingSource1.MoveLast(); 62 | TxtName.Focus(); 63 | } 64 | 65 | private void BtnSave_Click(object sender, EventArgs e) 66 | { 67 | try 68 | { 69 | using (BillingContext db = new BillingContext()) 70 | { 71 | var path = db.Settings.Take(1).FirstOrDefault(); 72 | if (customersBindingSource1.Current is Customers cat) 73 | { 74 | if (db.Entry(cat).State == EntityState.Detached) 75 | db.Set().Attach(cat); 76 | if (cat.CustomerId == 0) 77 | { 78 | db.Entry(cat).State = EntityState.Added; 79 | cat.CreatedDate = DateTime.Now; 80 | db.SaveChanges(); 81 | if (path.EnableSMS) 82 | { 83 | SMS.Sender.Send(TxtContact.Text.Trim(), "Greetings " + TxtName.Text.Trim() + ", Welcome to Carwest Auto Service"); 84 | } 85 | Message("Customer Added"); 86 | } 87 | else 88 | { 89 | db.Entry(cat).State = EntityState.Modified; 90 | cat.UpdatedDate = DateTime.Now; 91 | db.SaveChanges(); 92 | Message("Customer Modified"); 93 | } 94 | } 95 | } 96 | } 97 | catch (Exception ex) 98 | { 99 | ExportJson.Add(ex); 100 | Message(ex.ToString()); 101 | } 102 | finally 103 | { 104 | DGVCustomers.Refresh(); 105 | LoadDGV(); 106 | } 107 | } 108 | 109 | private void BtnDelete_Click(object sender, EventArgs e) 110 | { 111 | try 112 | { 113 | if (DGVCustomers.SelectedRows.Count > 0) 114 | { 115 | int CusId = Convert.ToInt32(TxtCustomerId.Text.Trim()); 116 | DialogResult dialogResult = MessageBox.Show("Are you sure you want to delete the selected Item?", "Confirmation delete", MessageBoxButtons.YesNo); 117 | if (dialogResult == DialogResult.Yes) 118 | { 119 | using (BillingContext db = new BillingContext()) 120 | { 121 | var cus = db.Customers.FirstOrDefault(c => c.CustomerId == CusId); 122 | if (cus != null) 123 | { 124 | if (db.Entry(cus).State == EntityState.Detached) 125 | db.Set().Attach(cus); 126 | cus.IsDeleted = true; 127 | cus.UpdatedDate = DateTime.Now; 128 | db.Entry(cus).State = EntityState.Modified; 129 | db.SaveChanges(); 130 | Message("Customer Deleted Successfully"); 131 | } 132 | } 133 | } 134 | } 135 | else 136 | { 137 | Info.Mes("Please select a customer to delete"); 138 | } 139 | } 140 | catch (Exception ex) 141 | { 142 | ExportJson.Add(ex); 143 | Message(ex.ToString()); 144 | } 145 | finally 146 | { 147 | DGVCustomers.Refresh(); 148 | LoadDGV(); 149 | } 150 | } 151 | 152 | private void BtnEdit_Click(object sender, EventArgs e) 153 | { 154 | CRUDPanel.Enabled = true; 155 | BtnSave.Enabled = true; 156 | BtnCancel.Enabled = true; 157 | TxtName.Focus(); 158 | _ = customersBindingSource1.Current as Customers; 159 | } 160 | 161 | private void DGVCustomers_CellClick(object sender, DataGridViewCellEventArgs e) 162 | { 163 | if (DGVCustomers.SelectedRows.Count > 0) 164 | { 165 | TxtCustomerId.Text = DGVCustomers.SelectedRows[0].Cells[0].Value + string.Empty; 166 | TxtName.Text = DGVCustomers.SelectedRows[0].Cells[1].Value + string.Empty; 167 | TxtContact.Text = DGVCustomers.SelectedRows[0].Cells[2].Value + string.Empty; 168 | TxtEmail.Text = DGVCustomers.SelectedRows[0].Cells[3].Value + string.Empty; 169 | TxtAddress.Text = DGVCustomers.SelectedRows[0].Cells[4].Value + string.Empty; 170 | 171 | BtnDelete.Enabled = true; 172 | BtnEdit.Enabled = true; 173 | BtnAdd.Enabled = true; 174 | } 175 | } 176 | 177 | private void TxtName_KeyUp(object sender, KeyEventArgs e) 178 | { 179 | Info.ToCapital(TxtName); 180 | } 181 | 182 | private void TxtAddress_KeyUp(object sender, KeyEventArgs e) 183 | { 184 | Info.ToCapital(TxtAddress); 185 | } 186 | 187 | private void TxtSearchCustomers_KeyUp(object sender, KeyEventArgs e) 188 | { 189 | Info.ToCapital(TxtSearchCustomers); 190 | Search(TxtSearchCustomers.Text.Trim()); 191 | } 192 | 193 | private void Search(string Input) 194 | { 195 | using (BillingContext db = new BillingContext()) 196 | { 197 | if (!string.IsNullOrWhiteSpace(Input)) 198 | { 199 | var data = (from cus in db.Customers.Where(c => !c.IsDeleted) 200 | select new 201 | { 202 | cus.CustomerId, 203 | cus.Name, 204 | cus.Contact, 205 | cus.Address, 206 | cus.Email 207 | }).Where(b => b.Name.Contains(Input) || b.Address.Contains(Input) || b.Contact.Contains(Input) || b.Email.Contains(Input)).ToList(); 208 | DGVCustomers.DataSource = data; 209 | } 210 | else 211 | { 212 | var data = (from cus in db.Customers.Where(c => !c.IsDeleted) 213 | select new 214 | { 215 | cus.CustomerId, 216 | cus.Name, 217 | cus.Contact, 218 | cus.Address, 219 | cus.Email 220 | }).ToList(); 221 | DGVCustomers.DataSource = data; 222 | } 223 | } 224 | } 225 | } 226 | } -------------------------------------------------------------------------------- /SimpleBilling/MasterForms/BusinessInfo.cs: -------------------------------------------------------------------------------- 1 | using SimpleBilling.Model; 2 | using System; 3 | using System.Data.Entity; 4 | using System.Drawing; 5 | using System.Linq; 6 | using System.Windows.Forms; 7 | 8 | namespace SimpleBilling.MasterForms 9 | { 10 | public partial class BusinessInfo : Form 11 | { 12 | public BusinessInfo() 13 | { 14 | InitializeComponent(); 15 | DGVLoad(); 16 | } 17 | 18 | private void BtnAdd_Click(object sender, EventArgs e) 19 | { 20 | CRUDLayout.Enabled = true; 21 | BtnSave.Enabled = true; 22 | BtnCancel.Enabled = true; 23 | TxtId.Text = "0"; 24 | TxtName.Focus(); 25 | } 26 | 27 | private void BusinessInfo_Load(object sender, EventArgs e) 28 | { 29 | DGVLoad(); 30 | } 31 | 32 | private void DGVLoad() 33 | { 34 | CRUDLayout.Enabled = false; 35 | BtnSave.Enabled = false; 36 | BtnCancel.Enabled = false; 37 | using (BillingContext db = new BillingContext()) 38 | { 39 | var data = (from bm in db.BusinessModels.Where(c => !c.IsDeleted) 40 | select new 41 | { 42 | bm.Id, 43 | bm.Name, 44 | bm.Address, 45 | bm.Contact, 46 | bm.IsActive 47 | }).ToList(); 48 | DGVBusinessInfo.DataSource = data; 49 | } 50 | BtnActivate.Enabled = false; 51 | DGVBusinessInfo_CellFormatting(); 52 | } 53 | 54 | private void BtnActivate_Click(object sender, EventArgs e) 55 | { 56 | try 57 | { 58 | if (DGVBusinessInfo.SelectedRows.Count > 0) 59 | { 60 | int id = Convert.ToInt32(DGVBusinessInfo.SelectedRows[0].Cells[0].Value + string.Empty); 61 | using (BillingContext db = new BillingContext()) 62 | { 63 | var item = db.BusinessModels.FirstOrDefault(c => c.Id == id); 64 | var data = db.BusinessModels.Where(c => c.Id != id).ToList(); 65 | foreach (var d in data) 66 | { 67 | d.IsActive = false; 68 | db.Entry(d).State = EntityState.Modified; 69 | } 70 | item.IsActive = true; 71 | db.Entry(item).State = EntityState.Modified; 72 | db.SaveChanges(); 73 | } 74 | } 75 | } 76 | catch (Exception ex) 77 | { 78 | ExportJson.Add(ex); Info.Mes(ex.Message); 79 | } 80 | finally 81 | { 82 | DGVLoad(); 83 | } 84 | } 85 | 86 | private void BtnSave_Click(object sender, EventArgs e) 87 | { 88 | try 89 | { 90 | using (BillingContext db = new BillingContext()) 91 | { 92 | int Id = Convert.ToInt32(TxtId.Text.Trim()); 93 | if (Id == 0) 94 | { 95 | if (Info.IsEmpty(TxtName) && Info.IsEmpty(TxtAddress) && Info.IsEmpty(TxtContact)) 96 | { 97 | BusinessModel bm = new BusinessModel 98 | { 99 | Name = TxtName.Text.Trim(), 100 | Address = TxtAddress.Text.Trim(), 101 | Contact = TxtContact.Text.Trim(), 102 | CreatedDate = DateTime.Now 103 | }; 104 | if (db.Entry(bm).State == EntityState.Detached) 105 | db.Set().Attach(bm); 106 | db.Entry(bm).State = EntityState.Added; 107 | db.SaveChanges(); 108 | Info.Mes("Business Info Added"); 109 | } 110 | else 111 | { 112 | Info.Required(); 113 | } 114 | } 115 | else 116 | { 117 | var bm = db.BusinessModels.FirstOrDefault(c => c.Id == Id); 118 | if (Info.IsEmpty(TxtName) && Info.IsEmpty(TxtAddress) && Info.IsEmpty(TxtContact)) 119 | { 120 | bm.Name = TxtName.Text.Trim(); 121 | bm.Address = TxtAddress.Text.Trim(); 122 | bm.Contact = TxtContact.Text.Trim(); 123 | bm.UpdatedDate = DateTime.Now; 124 | if (db.Entry(bm).State == EntityState.Detached) 125 | db.Set().Attach(bm); 126 | db.Entry(bm).State = EntityState.Modified; 127 | db.SaveChanges(); 128 | Info.Mes("Business Info Modified"); 129 | } 130 | else 131 | { 132 | Info.Required(); 133 | } 134 | } 135 | } 136 | } 137 | catch (Exception ex) 138 | { 139 | ExportJson.Add(ex); Info.Mes(ex.Message); 140 | } 141 | finally 142 | { 143 | DGVLoad(); 144 | CRUDLayout.Enabled = false; 145 | BtnSave.Enabled = false; 146 | BtnCancel.Enabled = false; 147 | } 148 | } 149 | 150 | private void BtnEdit_Click(object sender, EventArgs e) 151 | { 152 | CRUDLayout.Enabled = true; 153 | BtnSave.Enabled = true; 154 | BtnCancel.Enabled = true; 155 | TxtName.Focus(); 156 | } 157 | 158 | private void BtnDelete_Click(object sender, EventArgs e) 159 | { 160 | try 161 | { 162 | DialogResult dialogResult = MessageBox.Show("Are you sure you want to delete the selected Item?", "Confirmation delete", MessageBoxButtons.YesNo); 163 | if (dialogResult == DialogResult.Yes) 164 | { 165 | using (BillingContext db = new BillingContext()) 166 | { 167 | if (DGVBusinessInfo.SelectedRows.Count > 0) 168 | { 169 | int id = Convert.ToInt32(DGVBusinessInfo.SelectedRows[0].Cells[0].Value + string.Empty); 170 | var model = db.BusinessModels.FirstOrDefault(c => c.Id == id); 171 | model.IsDeleted = true; 172 | if (db.Entry(model).State == EntityState.Detached) 173 | db.Set().Attach(model); 174 | model.UpdatedDate = DateTime.Now; 175 | db.Entry(model).State = EntityState.Modified; 176 | db.SaveChangesAsync(); 177 | Info.Mes("Business Info Deleted Successfully"); 178 | } 179 | } 180 | } 181 | } 182 | catch (Exception ex) 183 | { 184 | Info.Mes(ex.ToString()); 185 | } 186 | finally 187 | { 188 | DGVBusinessInfo.Refresh(); 189 | DGVLoad(); 190 | } 191 | } 192 | 193 | private void BtnCancel_Click(object sender, EventArgs e) 194 | { 195 | CRUDLayout.Enabled = false; 196 | BtnSave.Enabled = false; 197 | } 198 | 199 | private void DGVBusinessInfo_CellFormatting() 200 | { 201 | foreach (DataGridViewRow Myrow in DGVBusinessInfo.Rows) 202 | { 203 | if (Convert.ToBoolean(Myrow.Cells[4].Value)) 204 | { 205 | Myrow.DefaultCellStyle.BackColor = Color.SkyBlue; 206 | } 207 | } 208 | } 209 | 210 | private void DGVBusinessInfo_CellClick(object sender, DataGridViewCellEventArgs e) 211 | { 212 | if (DGVBusinessInfo.SelectedRows.Count > 0) 213 | { 214 | BtnActivate.Enabled = true; 215 | TxtId.Text = DGVBusinessInfo.SelectedRows[0].Cells[0].Value + string.Empty; 216 | TxtName.Text = DGVBusinessInfo.SelectedRows[0].Cells[1].Value + string.Empty; 217 | TxtAddress.Text = DGVBusinessInfo.SelectedRows[0].Cells[2].Value + string.Empty; 218 | TxtContact.Text = DGVBusinessInfo.SelectedRows[0].Cells[3].Value + string.Empty; 219 | } 220 | } 221 | 222 | private void TxtName_KeyUp(object sender, KeyEventArgs e) 223 | { 224 | Info.ToCapital(TxtName); 225 | } 226 | 227 | private void TxtAddress_KeyUp(object sender, KeyEventArgs e) 228 | { 229 | Info.ToCapital(TxtAddress); 230 | } 231 | } 232 | } --------------------------------------------------------------------------------