Exemplo n.º 1
0
        public int Save(Models.MPayrollDetails model)
        {
            Common.Logger l         = new Common.Logger();
            string        ClassName = "CPayrollDetails";

            try
            {
                DB.PayrollDetail bs = new DB.PayrollDetail();
                bs.id            = Convert.ToInt32(model.PayrollId);
                bs.LastMonthPaid = model.LastMonthPaid;


                l.Print(ClassName, Common.LogPointer.Info.ToString(), "Model Values id[" + model.id + "] PayrollId[" + model.PayrollId + "] LastMonthPaid[" + model.LastMonthPaid + "] ");
                obj.PayrollDetails.InsertOnSubmit(bs);
                obj.SubmitChanges();
                l.Print(ClassName, Common.LogPointer.Info.ToString(), "Record Inserted Successfully");
                return(1);
            }
            catch (Exception ex)
            {
                l.Print(ClassName, Common.LogPointer.Error.ToString(), ex.ToString());
                return(-1);
            }
        }
Exemplo n.º 2
0
        public int Save(Models.MRoles model)
        {
            Common.Logger l         = new Common.Logger();
            string        ClassName = "CRoles";

            try
            {
                DB.Role bs = new DB.Role();
                //bs.id = int.Parse(model.id);
                bs.RoleName = model.RoleName;


                l.Print(ClassName, Common.LogPointer.Info.ToString(), "Model Values id[" + model.id + "] RoleName[" + model.RoleName + "] ");
                obj.Roles.InsertOnSubmit(bs);
                obj.SubmitChanges();
                l.Print(ClassName, Common.LogPointer.Info.ToString(), "Record Inserted Successfully");
                return(1);
            }
            catch (Exception ex)
            {
                l.Print(ClassName, Common.LogPointer.Error.ToString(), ex.ToString());
                return(-1);
            }
        }
Exemplo n.º 3
0
        public int Save(Models.MUserRolesContainer model)
        {
            Common.Logger l         = new Common.Logger();
            string        ClassName = "CUserRolesContainer";

            try
            {
                DB.UserRolesContainer bs = new DB.UserRolesContainer();
                bs.id     = int.Parse(model.id);
                bs.userId = int.Parse(model.userId);


                l.Print(ClassName, Common.LogPointer.Info.ToString(), "Model Values id[" + model.id + "] userId[" + model.userId + "] RolesId[" + model.Rolesid + "] ");
                obj.UserRolesContainers.InsertOnSubmit(bs);
                obj.SubmitChanges();
                l.Print(ClassName, Common.LogPointer.Info.ToString(), "Record Inserted Successfully");
                return(1);
            }
            catch (Exception ex)
            {
                l.Print(ClassName, Common.LogPointer.Error.ToString(), ex.ToString());
                return(-1);
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// Initializes a new instance of the <see cref="MainWindow"/> class.
        /// </summary>
        public MainWindow()
        {
            // DO NOT REORDER variable instantiation unless you know what you are doing!!!

            InitializeComponent();

            // Settings should come first
            Settings.Instance = Settings.Load(Utilities.GetAppDataPath() + "Settings.xml");
            if (Settings.Instance == null)
            {
                SettingsWindow win = new SettingsWindow();
                Settings.Instance = new Settings();
                win.ShowDialog();
            }

            // File System must be set after settings
            FileSystem = new Common.FileSystem.IO(Settings.Instance.StorageLocation);

            // Logger can be started after FileSystem
            Logger = new Common.Logger(Utilities.GetAppDataPath());

            // CouchDB can be instantiated after both FileSystem and Logger
            _couchdb = new Common.CouchDB.Database(Settings.Instance.CouchDatabaseName,
                new Common.CouchDB.Server(Settings.Instance.CouchServerIp, Settings.Instance.CouchServerPort));

            Common.ErrorManager.UpdateUI actErrorUpdateUI = ErrorUpdateUI;

            ErrorManager = new Common.ErrorManager(actErrorUpdateUI);
            _statusBarItemGuid = Guid.Empty;
            _workMaster = new Master(ErrorManager, FileSystem, _couchdb);
            IdTranslation = new Dictionary<Guid, Guid>();
            _fsWatcher = new FileSystemWatcher(Settings.Instance.StorageLocation);
            _fsWatcher.IncludeSubdirectories = true;
            _fsWatcher.NotifyFilter = NotifyFilters.LastWrite;
            _fsWatcher.Changed += new FileSystemEventHandler(FS_Changed);
            _fsWatcher.EnableRaisingEvents = true;
            _addedFileMappings = new Dictionary<string, Guid>();
            this.Loaded += new RoutedEventHandler(MainWindow_Loaded);


            ResourceTree.OnRelease += new ResourceTreeView.EventDelegate(ResourceTree_OnRelease);
            ResourceTree.OnCancel += new ResourceTreeView.EventDelegate(ResourceTree_OnCancel);
            ResourceTree.OnItemSelect += new ResourceTreeView.EventDelegate(ResourceTree_OnItemSelect);
            ResourceTree.OnReload += new ResourceTreeView.EventDelegate(ResourceTree_OnReload);
            ResourceTree.OnStatusUpdate += new ResourceTreeView.StatusUpdateDelegate(ResourceTree_OnStatusUpdate);

            ResourceTree.RegisterStatusBarItem(SBItem);
        }
        public void GetReleaseKeyTest()
        {
            var version = DotNetVersionCheck.GetReleaseKey();

            Logger.Info("Version: " + version);
        }
Exemplo n.º 6
0
        public int Save(Models.MInventory model, Common.Constants.SaleTransactions transaction)
        {
            Common.Logger l         = new Common.Logger();
            string        ClassName = "CInventory";

            try
            {
                string              totalUnitsofProducts = string.Empty;
                DB.Inventory        bs = new DB.Inventory();
                DB.InventoryBalance iv = new DB.InventoryBalance();
                switch (transaction)
                {
                    #region Addition Indentory
                case Common.Constants.SaleTransactions.Addition:
                {
                    #region Updating Inventory
                    var query = (from o in obj.Inventories
                                 where Convert.ToInt32(model.WareHouseld) == o.WareHouseId &&
                                 o.ProductId == Convert.ToInt32(model.ProductId) &&
                                 o.Cost == model.Cost
                                 select o.Quantity).FirstOrDefault();

                    if (query == null)
                    {
                        totalUnitsofProducts = model.Quantity;
                        //Inventory
                        bs.ProductId    = int.Parse(model.ProductId);
                        bs.WareHouseId  = int.Parse(model.WareHouseld);
                        bs.Cost         = model.Cost;
                        bs.date         = model.Date;
                        bs.Quantity     = totalUnitsofProducts;
                        bs.FiscalYearId = int.Parse(model.FiscalYearld);
                        l.Print(ClassName, Common.LogPointer.Info.ToString(), "Model Values id[" + model.id + "] ProductId[" + model.ProductId + "] WareHouseId[" + model.WareHouseld + "] Cost[" + model.Cost + "] Quantity[ " + model.Cost + "] FiscalYearId[ " + model.FiscalYearld + " ] ");
                        obj.Inventories.InsertOnSubmit(bs);
                        obj.SubmitChanges();
                        l.Print(ClassName, Common.LogPointer.Info.ToString(), "Record Inserted Successfully");
                    }
                    else
                    {
                        totalUnitsofProducts = query;
                        float Quantity = 0;
                        Quantity = Convert.ToSingle(totalUnitsofProducts)
                                   + Convert.ToSingle(model.Quantity);
                        var Data = (from o in obj.Inventories
                                    where Convert.ToInt32(model.WareHouseld) == o.WareHouseId &&
                                    o.ProductId == Convert.ToInt32(model.ProductId) &&
                                    o.Cost == model.Cost
                                    select o);
                        foreach (var item in Data)
                        {
                            item.ProductId   = Convert.ToInt32(model.ProductId);
                            item.Quantity    = Convert.ToString(Quantity);
                            item.Cost        = model.Cost;
                            item.WareHouseId = Convert.ToInt32(model.WareHouseld);
                            item.date        = model.Date;
                        }


                        obj.SubmitChanges();
                    }
                    #endregion

                    #region updating Inventory Balance
                    var invenotryBalance = (from o in obj.InventoryBalances
                                            where o.ProductsId == Convert.ToInt32(model.ProductId) &&
                                            o.WarehouseId == Convert.ToInt32(model.WareHouseld)
                                            orderby o.id ascending
                                            select o);
                    if (!invenotryBalance.Any())
                    {
                        iv.Date              = Convert.ToDateTime(model.Date);
                        iv.ProductsId        = Convert.ToInt32(model.ProductId);
                        iv.WarehouseId       = Convert.ToInt32(model.WareHouseld);
                        iv.PurchaseUnitsCost = model.Cost;
                        iv.PurchaseUnits     = model.Quantity;
                        float PurchaseTotal = Convert.ToSingle(Convert.ToSingle(model.Cost) * Convert.ToSingle(model.Quantity));
                        iv.PurchaseTotal    = PurchaseTotal.ToString();
                        iv.BalanceUnitsCost = model.Cost;
                        iv.BalanceUnits     = model.Quantity;
                        iv.BalanceTotal     = PurchaseTotal.ToString();
                        obj.InventoryBalances.InsertOnSubmit(iv);
                        obj.SubmitChanges();
                    }
                    else
                    {
                        float oldUnits = 0, oldCost = 0, oldTotal = 0,
                              newTotal = 0, newUnits = 0, newCost = 0;
                        foreach (var item in invenotryBalance)
                        {
                            oldUnits = Convert.ToSingle(item.BalanceUnits);
                            oldCost  = Convert.ToSingle(item.BalanceUnitsCost);
                            oldTotal = Convert.ToSingle(item.BalanceTotal);
                            newUnits = oldUnits + Convert.ToSingle(model.Quantity);
                            newCost  = Convert.ToSingle(model.Cost);
                            newTotal = Convert.ToSingle(newUnits * newCost);
                        }
                        iv.Date              = Convert.ToDateTime(model.Date);
                        iv.ProductsId        = Convert.ToInt32(model.ProductId);
                        iv.WarehouseId       = Convert.ToInt32(model.WareHouseld);
                        iv.PurchaseUnitsCost = model.Cost;
                        iv.PurchaseUnits     = model.Quantity;
                        float PurchaseTotal = Convert.ToSingle(Convert.ToSingle(model.Cost) * Convert.ToSingle(model.Quantity));
                        iv.PurchaseTotal    = PurchaseTotal.ToString();
                        iv.BalanceUnitsCost = newCost.ToString();
                        iv.BalanceUnits     = newUnits.ToString();
                        iv.BalanceTotal     = newTotal.ToString();
                        obj.InventoryBalances.InsertOnSubmit(iv);
                        obj.SubmitChanges();
                    }


                    #endregion

                    break;
                }
                    #endregion

                    #region Deduction Indentory

                case Common.Constants.SaleTransactions.Deduction:
                {
                    #region Updating Inventory
                    var query = (from o in obj.Inventories
                                 where Convert.ToInt32(model.WareHouseld) == o.WareHouseId &&
                                 o.ProductId == Convert.ToInt32(model.ProductId) &&
                                 o.Cost == model.Cost
                                 orderby o.date
                                 select o.Quantity).FirstOrDefault();
                    if (query == null)
                    {
                        return(0);
                    }
                    else
                    {
                        totalUnitsofProducts = query;
                        float Quantity = 0;
                        Quantity = Convert.ToSingle(totalUnitsofProducts)
                                   - Convert.ToSingle(model.Quantity);
                        if (Quantity < 0)
                        {
                            //Quantity not found in warehouse/Invenotry
                            return(0);
                        }

                        var Data = (from o in obj.Inventories
                                    where Convert.ToInt32(model.WareHouseld) == o.WareHouseId &&
                                    o.ProductId == Convert.ToInt32(model.ProductId) &&
                                    model.Cost == model.Cost
                                    select o);
                        foreach (var item in Data)
                        {
                            item.ProductId   = Convert.ToInt32(model.ProductId);
                            item.Quantity    = Convert.ToString(Quantity);
                            item.Cost        = model.Cost;
                            item.WareHouseId = Convert.ToInt32(model.WareHouseld);
                            bs.date          = model.Date;
                        }

                        obj.SubmitChanges();
                    }
                    #endregion

                    #region Updating Inventory Balance
                    var invenotryBalance = (from o in obj.InventoryBalances
                                            where o.ProductsId == Convert.ToInt32(model.ProductId) &&
                                            o.WarehouseId == Convert.ToInt32(model.WareHouseld)
                                            orderby o.id ascending
                                            select o);
                    if (!invenotryBalance.Any())
                    {
                        iv.Date          = Convert.ToDateTime(model.Date);
                        iv.ProductsId    = Convert.ToInt32(model.ProductId);
                        iv.WarehouseId   = Convert.ToInt32(model.WareHouseld);
                        iv.SaleUnitsCost = model.Cost;
                        iv.SaleUnits     = model.Quantity;
                        float PurchaseTotal = Convert.ToSingle(Convert.ToSingle(model.Cost) * Convert.ToSingle(model.Quantity));
                        iv.SaleTotal        = PurchaseTotal.ToString();
                        iv.BalanceUnitsCost = model.Cost;
                        iv.BalanceUnits     = model.Quantity;
                        iv.BalanceTotal     = PurchaseTotal.ToString();
                        obj.InventoryBalances.InsertOnSubmit(iv);
                        obj.SubmitChanges();
                    }
                    else
                    {
                        float oldUnits = 0, oldCost = 0, oldTotal = 0,
                              newTotal = 0, newUnits = 0, newCost = 0;
                        foreach (var item in invenotryBalance)
                        {
                            oldUnits = Convert.ToSingle(item.BalanceUnits);
                            oldCost  = Convert.ToSingle(item.BalanceUnitsCost);
                            oldTotal = Convert.ToSingle(item.BalanceTotal);
                            newUnits = oldUnits - Convert.ToSingle(model.Quantity);
                            newCost  = Convert.ToSingle(model.Cost);
                            newTotal = Convert.ToSingle(newUnits * newCost);
                        }
                        iv.Date          = Convert.ToDateTime(model.Date);
                        iv.ProductsId    = Convert.ToInt32(model.ProductId);
                        iv.WarehouseId   = Convert.ToInt32(model.WareHouseld);
                        iv.SaleUnitsCost = model.Cost;
                        iv.SaleUnits     = model.Quantity;
                        float PurchaseTotal = Convert.ToSingle(Convert.ToSingle(model.Cost) * Convert.ToSingle(model.Quantity));
                        iv.SaleTotal        = PurchaseTotal.ToString();
                        iv.BalanceUnitsCost = newCost.ToString();
                        iv.BalanceUnits     = newUnits.ToString();
                        iv.BalanceTotal     = newTotal.ToString();
                        obj.InventoryBalances.InsertOnSubmit(iv);
                        obj.SubmitChanges();
                    }


                    #endregion

                    break;
                }

                    #endregion

                    #region Transfer Inventory
                case Common.Constants.SaleTransactions.Transfer:
                {
                    break;
                }

                    #endregion

                default:
                {
                    totalUnitsofProducts = "0";
                    break;
                }
                }



                return(1);
            }
            catch (Exception ex)
            {
                l.Print(ClassName, Common.LogPointer.Error.ToString(), ex.ToString());
                return(-1);
            }
        }
Exemplo n.º 7
0
        public int Save(Models.MSaleTransactions model)
        {
            Common.Logger l         = new Common.Logger();
            string        ClassName = "CSaleTransaction";

            try
            {
                DB.Transaction1 bs = new DB.Transaction1();
                bs.id              = Convert.ToInt32(model.id);
                bs.ProductID       = Convert.ToInt32(model.ProductID);
                bs.CostPrice       = model.CostPrice;
                bs.SalePrice       = model.SalePrice;
                bs.units           = model.units;
                bs.TransactionType = model.transactionType;
                bs.VendorID        = model.VendorID;
                bs.ClientID        = model.clientID;
                bs.OrderId         = Convert.ToInt32(model.OrderId);
                bs.WareHouseId     = Convert.ToInt32(model.WareHouseId);
                bs.date            = model.date;

                l.Print(ClassName, Common.LogPointer.Info.ToString(), "Model Values id[" + model.id + "] ProductID[" + model.ProductID + "] CostPrice[" + model.CostPrice + "] SalePrice[" + model.SalePrice + "] units [ " + model.units + "] TransactionType [ " + model.transactionType + " ]  ClientID [ " + model.clientID + " ] VendorID [ " + model.VendorID + " ] date [ " + model.date + " ]");
                obj.Transaction1s.InsertOnSubmit(bs);
                obj.SubmitChanges();


                if (model.transactionType == Common.Constants.SaleTransactions.Addition.ToString())
                {
                    Classes.CJournal cj = new CJournal();
                    DB.Journal       j  = new DB.Journal();
                    j.acc_id = Convert.ToInt32(Common.Constants.Accounts.ChartOfAccounts.MerchandiseInventory);
                    j.amount = Convert.ToSingle(Convert.ToSingle(bs.CostPrice) * Convert.ToSingle(bs.units)) - Convert.ToSingle(model.Discount);
                    j.des    = "Purchased Inventory [" + bs.units + "] ";
                    j.e_date = Convert.ToDateTime(model.date);
                    j.type   = Common.Constants.Accounts.Type.Debit.ToString();
                    obj.Journals.InsertOnSubmit(j);
                    obj.SubmitChanges();

                    if (Convert.ToSingle(model.Discount) > 0)
                    {
                        j        = new DB.Journal();
                        j.acc_id = Convert.ToInt32(Common.Constants.Accounts.ChartOfAccounts.PurchaseDiscount);
                        j.amount = Convert.ToSingle(model.Discount);
                        j.des    = "Purchased Inventory Discount [" + bs.units + "] ";
                        j.e_date = Convert.ToDateTime(model.date);
                        j.type   = Common.Constants.Accounts.Type.Debit.ToString();
                        obj.Journals.InsertOnSubmit(j);
                        obj.SubmitChanges();
                    }


                    j        = new DB.Journal();
                    j.acc_id = Convert.ToInt32(Common.Constants.Accounts.ChartOfAccounts.Cash);
                    j.amount = Convert.ToSingle(Convert.ToSingle(bs.CostPrice) * Convert.ToSingle(bs.units));
                    j.des    = "Purchased Inventory [" + bs.units + "] ";
                    j.e_date = Convert.ToDateTime(model.date);
                    j.type   = Common.Constants.Accounts.Type.Credit.ToString();
                    obj.Journals.InsertOnSubmit(j);
                    obj.SubmitChanges();
                }
                else if (model.transactionType == Common.Constants.SaleTransactions.Deduction.ToString())
                {
                    Classes.CJournal cj = new CJournal();
                    DB.Journal       j  = new DB.Journal();
                    j.acc_id = Convert.ToInt32(Common.Constants.Accounts.ChartOfAccounts.Cash);
                    j.amount = Convert.ToSingle(Convert.ToSingle(bs.CostPrice) * Convert.ToSingle(bs.units)) - Convert.ToSingle(model.Discount);
                    j.des    = "Sold Inventory [" + bs.units + "] ";
                    j.e_date = Convert.ToDateTime(model.date);
                    j.type   = Common.Constants.Accounts.Type.Debit.ToString();
                    obj.Journals.InsertOnSubmit(j);
                    obj.SubmitChanges();

                    if (Convert.ToSingle(model.Discount) > 0)
                    {
                        j        = new DB.Journal();
                        j.acc_id = Convert.ToInt32(Common.Constants.Accounts.ChartOfAccounts.SalesDiscount);
                        j.amount = Convert.ToSingle(model.Discount);
                        j.des    = "Sold Inventory Discount [" + bs.units + "] ";
                        j.e_date = Convert.ToDateTime(model.date);
                        j.type   = Common.Constants.Accounts.Type.Debit.ToString();
                        obj.Journals.InsertOnSubmit(j);
                        obj.SubmitChanges();
                    }


                    j        = new DB.Journal();
                    j.acc_id = Convert.ToInt32(Common.Constants.Accounts.ChartOfAccounts.Sales);
                    j.amount = Convert.ToSingle(Convert.ToSingle(bs.CostPrice) * Convert.ToSingle(bs.units));
                    j.des    = "Sold Inventory [" + bs.units + "] ";
                    j.e_date = Convert.ToDateTime(model.date);
                    j.type   = Common.Constants.Accounts.Type.Credit.ToString();
                    obj.Journals.InsertOnSubmit(j);
                    obj.SubmitChanges();



                    cj       = new CJournal();
                    j        = new DB.Journal();
                    j.acc_id = Convert.ToInt32(Common.Constants.Accounts.ChartOfAccounts.CostOfGoodsSold);
                    j.amount = Convert.ToSingle(Convert.ToSingle(bs.CostPrice) * Convert.ToSingle(bs.units));
                    j.des    = "Sold Inventory [" + bs.units + "] ";
                    j.e_date = Convert.ToDateTime(model.date);
                    j.type   = Common.Constants.Accounts.Type.Debit.ToString();
                    obj.Journals.InsertOnSubmit(j);
                    obj.SubmitChanges();

                    j        = new DB.Journal();
                    j.acc_id = Convert.ToInt32(Common.Constants.Accounts.ChartOfAccounts.MerchandiseInventory);
                    j.amount = Convert.ToSingle(Convert.ToSingle(bs.CostPrice) * Convert.ToSingle(bs.units));
                    j.des    = "Sold Inventory [" + bs.units + "] ";
                    j.e_date = Convert.ToDateTime(model.date);
                    j.type   = Common.Constants.Accounts.Type.Credit.ToString();
                    obj.Journals.InsertOnSubmit(j);
                    obj.SubmitChanges();
                }


                l.Print(ClassName, Common.LogPointer.Info.ToString(), "Record Inserted Successfully");
                return(1);
            }
            catch (Exception ex)
            {
                l.Print(ClassName, Common.LogPointer.Error.ToString(), ex.ToString());
                return(-1);
            }
        }