Esempio n. 1
0
        public int InsertCustomer(CustomerModel item)
        {
            int result = 0;

            try
            {
                var client = new CLIENT();
                client.Lname                 = item.Lname;
                client.Fname                 = item.Fname;
                client.Phone                 = item.Phone;
                client.Adress1               = item.Adress1;
                client.Adress2               = item.Adress2;
                client.Adress3               = item.Adress3;
                client.Email                 = item.Email;
                client.Country               = item.Country;
                client.Note                  = item.Note;
                client.Balance               = item.Balance;
                client.Status                = item.Status;
                client.CreateBy              = item.CreateBy ?? 0;
                client.CreateDate            = DateTime.Now;
                client.UpdateBy              = item.UpdateBy ?? 0;
                client.UpdateDate            = DateTime.Now;
                _context.Entry(client).State = System.Data.Entity.EntityState.Added;
                _context.SaveChanges();
                result = 1;
            }
            catch (Exception ex)
            {
                LogPOS.WriteLog("CustomerService:::::::::::::::::::::InsertCustomer::::::::::::::::;;" + ex.Message);
            }
            return(result);
        }
Esempio n. 2
0
        public int InsertDataShiftHistory(ShiftHistoryModel model)
        {
            try
            {
                var data = new SHIFT_HISTORY();

                data.ShiftName = model.ShiftName ?? "";
                data.StaffID   = model.StaffID;
                data.CashStart = model.CashStart;

                data.Status     = 1;
                data.StartShift = DateTime.Now;

                data.CreateBy   = model.CreateBy;
                data.CreateDate = DateTime.Now;

                _context.Entry(data).State = EntityState.Added;
                _context.SaveChanges();


                return(data.ShiftHistoryID);
            }
            catch (Exception ex)
            {
                LogPOS.WriteLog("SaveDataStaff :::::::::::::::::::::::::" + ex.Message);
                return(0);
            }
        }
Esempio n. 3
0
        public int BackupDatabaseSetting(int userid)
        {
            try
            {
                var    datapath = _context.CONFIG_SAVE_DATA.Where(x => x.Type == 1).FirstOrDefault();
                string filepath = "F:\\POSEZ2U_" + DateTime.Now.ToString("dd-MM-yyyy", CultureInfo.InvariantCulture) + ".Bak";

                if (datapath != null)
                {
                    filepath = datapath.LinkPath + "POSEZ2U_" + DateTime.Now.ToString("dd-MM-yyyy", CultureInfo.InvariantCulture) + ".Bak";
                }

                string dbname     = _context.Database.Connection.Database;
                string sqlCommand = @"BACKUP DATABASE POSEZ2U TO DISK = '" + filepath + "'";
                _context.Database.ExecuteSqlCommand(System.Data.Entity.TransactionalBehavior.DoNotEnsureTransaction, string.Format(sqlCommand, dbname, filepath));


                var datatable = new DATABASE_BACKUP();
                datatable.FileName   = filepath;
                datatable.Notes      = filepath;
                datatable.CreateBy   = userid;
                datatable.CreateDate = DateTime.Now;

                _context.Entry(datatable).State = System.Data.Entity.EntityState.Added;
                _context.SaveChanges();

                return(1);
            }
            catch (Exception)
            {
                return(0);
            }
        }
Esempio n. 4
0
        public int InsertPrinter(Model.PrinterModel Printer)
        {
            int result = 0;

            try
            {
                if (Printer != null)
                {
                    var item = new PRINTER();
                    item.PrinterName           = Printer.PrinterName;
                    item.PrintName             = Printer.PrintName;
                    item.PrinterType           = Printer.PrinterType;
                    item.Status                = Printer.Status;
                    item.CreateBy              = Printer.CreateBy ?? 0;
                    item.CreateDate            = DateTime.Now;
                    item.UpdateBy              = Printer.UpdateBy ?? 0;
                    item.UpdateDate            = DateTime.Now;
                    _context.Entry(item).State = System.Data.Entity.EntityState.Added;
                    _context.SaveChanges();
                    result = 1;
                }
            }
            catch (Exception ex)
            {
                LogPOS.WriteLog(className + "InsertPrinter:::::::::::::::::::;;" + ex.Message);
            }
            return(result);
        }
Esempio n. 5
0
        public int InsertPrinterMapping(Model.PrinteJobDetailModel PrinterJob)
        {
            int result = 0;

            try
            {
                PRINTE_JOB_DETAIL item = new PRINTE_JOB_DETAIL();
                item.CategoryID            = PrinterJob.CategoryID;
                item.ProductID             = PrinterJob.ProductID;
                item.PrinterID             = PrinterJob.PrinterID;
                item.Status                = 1;
                _context.Entry(item).State = System.Data.Entity.EntityState.Added;
                _context.SaveChanges();
                result = 1;
            }
            catch (Exception ex)
            {
            }
            return(result);
        }
Esempio n. 6
0
        public int SavaDataCatalogue(CatalogueModel cata)
        {
            try
            {
                if (cata.CatalogueID == 0)
                {
                    var checkdata = _context.CATALOGUEs.Where(x => x.CatalogueName == cata.CatalogueName).ToList();
                    if (checkdata.Count() > 0)
                    {
                        return(-1);
                    }

                    var data = new CATALOGUE();
                    data.CatalogueName = cata.CatalogueName;
                    data.Color         = cata.Color ?? "";
                    data.Status        = 1;
                    data.CreateBy      = cata.CreateBy ?? 0;
                    data.CreateDate    = DateTime.Now;
                    data.UpdateBy      = cata.UpdateBy ?? 0;
                    data.UpdateDate    = DateTime.Now;
                    data.Note          = cata.Note ?? "";

                    _context.Entry(data).State = EntityState.Added;
                    _context.SaveChanges();

                    return(1);
                }
                else
                {
                    var checkdata = _context.CATALOGUEs.Where(x => x.CatalogueName == cata.CatalogueName && x.CatalogueID != cata.CatalogueID).ToList();
                    if (checkdata.Count() > 0)
                    {
                        return(-1);
                    }
                    var data = _context.CATALOGUEs.Find(cata.CatalogueID);
                    if (data != null)
                    {
                        data.CatalogueName = cata.CatalogueName;
                        data.Color         = cata.Color ?? "";
                        data.Status        = 1;
                        data.UpdateBy      = cata.UpdateBy ?? 0;
                        data.UpdateDate    = DateTime.Now;
                        data.Note          = cata.Note ?? "";

                        _context.Entry(data).State = EntityState.Modified;
                        _context.SaveChanges();

                        return(1);
                    }
                    return(0);
                }
            }
            catch (Exception)
            {
                return(0);
            }
        }
Esempio n. 7
0
        public int EditProductPrice(ProductPriceModel productPriceData)
        {
            var data = _context.PRODUCT_PRICE.Find(productPriceData.ProductPriceID);

            if (data != null)
            {
                data.WasPrice              = data.CurrentPrice;
                data.CurrentPrice          = productPriceData.CurrentPrice;
                data.UpdateBy              = productPriceData.UpdateBy ?? 0;
                data.UpdateDate            = DateTime.Now;
                _context.Entry(data).State = EntityState.Modified;
                _context.SaveChanges();
                return(1);
            }
            else
            {
                return(0);
            }
        }
Esempio n. 8
0
        public int SaveDataDeparment(DepartmentModel data)
        {
            try
            {
                if (data.DepartmentID == 0)
                {
                    var departmentcheck = _context.DEPARTMENTs.Where(x => x.DepartmentName == data.DepartmentName).ToList();
                    if (departmentcheck.Count > 0)
                    {
                        return(-1);
                    }
                    var department = new DEPARTMENT();
                    department.DepartmentName = data.DepartmentName;
                    department.Status         = 1;
                    department.CreateBy       = data.UpdateBy;
                    department.CreateDate     = DateTime.Now;
                    department.UpdateBy       = data.UpdateBy;
                    department.UpdateDate     = DateTime.Now;

                    _context.Entry(department).State = EntityState.Added;
                    _context.SaveChanges();
                    return(1);
                }
                else
                {
                    var departmentcheck = _context.DEPARTMENTs.Where(x => x.DepartmentName == data.DepartmentName && x.DepartmentID != data.DepartmentID).ToList();
                    if (departmentcheck.Count > 0)
                    {
                        return(-1);
                    }
                    var department = _context.DEPARTMENTs.Find(data.DepartmentID);
                    if (department != null)
                    {
                        department.DepartmentName        = data.DepartmentName;
                        department.UpdateBy              = data.UpdateBy;
                        department.UpdateDate            = DateTime.Now;
                        _context.Entry(department).State = EntityState.Modified;
                        _context.SaveChanges();
                        return(1);
                    }
                    return(0);
                }
            }
            catch (Exception ex)
            {
                LogPOS.WriteLog("SaveDataDeparment :::::::::::::::::::::::::" + ex.Message);
                return(0);
            }
        }
Esempio n. 9
0
        public int InsertDebitAccount(AccountPaymentModel acc)
        {
            int result = 0;

            try
            {
                using (var tranx = _context.Database.BeginTransaction())
                {
                    ACC_PAYMENT Acc = new ACC_PAYMENT();
                    Acc.PayMentID             = acc.PayMentID;
                    Acc.InvoiceID             = 0;
                    Acc.InvoiceNumber         = 0;
                    Acc.SubTotal              = acc.SubTotal;
                    Acc.Card                  = acc.Card;
                    Acc.Cash                  = acc.Cash;
                    Acc.IsCredit              = 0;
                    Acc.IsDebit               = 1;
                    Acc.CreateBy              = 0;
                    Acc.CreateDate            = DateTime.Now;
                    Acc.UpdateBy              = 0;
                    Acc.UpdateDate            = DateTime.Now;
                    Acc.CusNo                 = acc.CusNo;
                    _context.Entry(Acc).State = System.Data.Entity.EntityState.Added;
                    _context.SaveChanges();
                    string sql = "update client set balance=balance+'" + Convert.ToInt32(acc.SubTotal) + "' where ClientID='" + acc.CusNo + "'";
                    _context.Database.ExecuteSqlCommand(sql);
                    tranx.Commit();
                    result = 1;
                }
            }
            catch (Exception ex)
            {
                LogPOS.WriteLog("AccountPaymentService:::::::::::::::::::::::::::InsertDebitAccount::::::::::::::" + ex.Message);
            }
            return(result);
        }
Esempio n. 10
0
        public int InsertInvoice(OrderDateModel Order)
        {
            int     result = 0;
            int     InvoiceID;
            INVOICE invoice = new INVOICE();
            List <INVOICE_DETAIL>          invoiceDEtail         = new List <INVOICE_DETAIL>();
            List <INVOICE_DETAIL_MODIFIRE> invoiceDetailModifier = new List <INVOICE_DETAIL_MODIFIRE>();
            List <PAYMENT_INVOICE_HISTORY> PaymentHistory        = new List <PAYMENT_INVOICE_HISTORY>();
            List <INVOICE_BY_CARD>         InvoiceByCard         = new List <INVOICE_BY_CARD>();
            ACC_PAYMENT Acc = new ACC_PAYMENT();

            using (var trans = _context.Database.BeginTransaction())
            {
                _context.Database.ExecuteSqlCommand("update ORDER_DATE set Status=1 where OrderID='" + Order.OrderID + "'");
                invoice = CopyInvoice(Order);
                _context.Entry(invoice).State = System.Data.Entity.EntityState.Added;
                _context.SaveChanges();
                InvoiceID = invoice.InvoiceID;
                string InvNum = InvoiceID + "" + DateTime.Now.Date.Year + "" + DateTime.Now.Date.Month + "" + DateTime.Now.Date.Day;
                _context.Database.ExecuteSqlCommand("update invoice set InvoiceNumber='" + InvNum + "'where InvoiceID='" + InvoiceID + "'");

                //Update balance for customer
                _context.Database.ExecuteSqlCommand("update client set balance=balance+'" + -Convert.ToInt32(Order.Payment) + "' where ClientID='" + Order.CusItem.ClientID + "'");
                Acc               = CopyAcc(Order);
                Acc.InvoiceID     = InvoiceID;
                Acc.InvoiceNumber = Convert.ToInt32(InvNum);
                //_context.Entry(Acc).State = System.Data.Entity.EntityState.Added;
                string sql = "insert into acc_payment(CusNo,SubTotal,InvoiceID,InvoiceNumber,Cash,Card,IsCredit,IsDebit,CreateDate,CreateBy,UpdateDate,UpdateBy)values(" +
                             "'" + Order.CusItem.ClientID + "','" + Convert.ToInt32(Order.Payment) + "','" + InvoiceID + "','" + Convert.ToInt32(InvNum) + "',0,0,1,0,'" + DateTime.Now + "','" + Order.ShiftID + "','" + DateTime.Now + "','" + Order.ShiftID + "')";
                _context.Database.ExecuteSqlCommand("insert into acc_payment(CusNo,SubTotal,InvoiceID,InvoiceNumber,Cash,Card,IsCredit,IsDebit,CreateDate,CreateBy,UpdateDate,UpdateBy)values(" +
                                                    "'" + Order.CusItem.ClientID + "','" + Convert.ToInt32(Order.Payment) + "','" + InvoiceID + "','" + Convert.ToInt32(InvNum) + "',0,0,1,0,'" + DateTime.Now + "','" + Order.ShiftID + "','" + DateTime.Now + "','" + Order.ShiftID + "')");
                //
                invoiceDEtail = CopyInvoicedetail(Order);
                foreach (INVOICE_DETAIL item in invoiceDEtail)
                {
                    item.InvoiceID             = InvoiceID;
                    item.InvoiceNumber         = Convert.ToInt32(InvNum);
                    _context.Entry(item).State = System.Data.Entity.EntityState.Added;
                }
                invoiceDetailModifier = CopyInvoiceMidifire(Order);

                foreach (INVOICE_DETAIL_MODIFIRE item in invoiceDetailModifier)
                {
                    item.InvoiceID     = InvoiceID;
                    item.InvoiceNumber = Convert.ToInt32(InvNum);

                    _context.Entry(item).State = System.Data.Entity.EntityState.Added;
                }

                PaymentHistory = CopyListPayment(Order);
                foreach (PAYMENT_INVOICE_HISTORY item in PaymentHistory)
                {
                    item.InvoiceID             = InvoiceID;
                    item.InvoiceNumber         = Convert.ToInt32(InvNum);
                    _context.Entry(item).State = System.Data.Entity.EntityState.Added;
                }

                InvoiceByCard = CopyInvoiceByCard(Order);
                foreach (INVOICE_BY_CARD item in InvoiceByCard)
                {
                    item.InvoiceID             = InvoiceID;
                    _context.Entry(item).State = System.Data.Entity.EntityState.Added;
                }

                _context.SaveChanges();
                trans.Commit();
                result = 1;
            }
            return(result);
        }
Esempio n. 11
0
        public int Created(ProductionModel data)
        {
            try
            {
                if (data.ProductID == 0)
                {
                    var checkdata = _context.PRODUCTs.Where(x => x.ProductNameDesc == data.ProductNameDesc).ToList();
                    if (checkdata.Count() > 0)
                    {
                        return(-1);
                    }

                    var new_data = new PRODUCT();
                    new_data.ProductNameDesc = data.ProductNameDesc;
                    new_data.ProductNameSort = data.ProductNameSort;
                    new_data.Color           = data.Color ?? "";
                    new_data.Status          = 1;
                    new_data.CreateBy        = data.CreateBy ?? 0;
                    new_data.CreateDate      = DateTime.Now;
                    new_data.UpdateBy        = data.UpdateBy ?? 0;
                    new_data.UpdateDate      = DateTime.Now;
                    new_data.Note            = data.Note ?? "";

                    _context.Entry(new_data).State = EntityState.Added;
                    _context.SaveChanges();
                    var product_price = new PRODUCT_PRICE();
                    product_price.ProductID    = new_data.ProductID;
                    product_price.CurrentPrice = data.CurrentPrice;
                    product_price.CreateBy     = data.CreateBy ?? 0;
                    product_price.CreateDate   = DateTime.Now;
                    product_price.UpdateBy     = data.UpdateBy ?? 0;
                    product_price.UpdateDate   = DateTime.Now;
                    product_price.Note         = data.Note ?? "";
                    var result = CreatedProductPrice(product_price);
                    return(result);
                }
                else
                {
                    var checkdata = _context.PRODUCTs.Where(x => x.ProductNameDesc == data.ProductNameDesc && x.ProductID != data.ProductID).ToList();
                    if (checkdata.Count() > 0)
                    {
                        return(-1);
                    }
                    var old_data = _context.PRODUCTs.Find(data.ProductID);
                    if (old_data != null)
                    {
                        old_data.ProductNameDesc = data.ProductNameDesc;
                        old_data.ProductNameSort = data.ProductNameSort;
                        old_data.Color           = data.Color ?? "";
                        old_data.Status          = 1;
                        old_data.UpdateBy        = data.UpdateBy ?? 0;
                        old_data.UpdateDate      = DateTime.Now;
                        old_data.Note            = data.Note ?? "";

                        _context.Entry(old_data).State = EntityState.Modified;
                        _context.SaveChanges();
                        var product_price = new PRODUCT_PRICE();
                        product_price.ProductID    = data.ProductID;
                        product_price.CurrentPrice = data.CurrentPrice;
                        product_price.CreateBy     = data.CreateBy ?? 0;
                        product_price.CreateDate   = DateTime.Now;
                        product_price.UpdateBy     = data.UpdateBy ?? 0;
                        product_price.UpdateDate   = DateTime.Now;
                        product_price.Note         = data.Note ?? "";
                        var result = CreatedProductPrice(product_price);
                        return(result);
                    }
                    return(0);
                }
            }
            catch (Exception ex)
            {
                return(0);
            }
        }
Esempio n. 12
0
        public int Created(ModifireModel data)
        {
            try
            {
                if (data.ModifireID == 0)
                {
                    var checkdata = _context.MODIFIREs.Where(x => x.ModifireName == data.ModifireName).ToList();
                    if (checkdata.Count() > 0)
                    {
                        return(-1);
                    }

                    var new_data = new MODIFIRE();
                    new_data.ModifireName = data.ModifireName;
                    new_data.Color        = data.Color ?? "";
                    new_data.Status       = 1;
                    new_data.CreateBy     = data.CreateBy ?? 0;
                    new_data.CreateDate   = DateTime.Now;
                    new_data.UpdateBy     = data.UpdateBy ?? 0;
                    new_data.UpdateDate   = DateTime.Now;
                    new_data.Note         = data.Note ?? "";

                    _context.Entry(new_data).State = EntityState.Added;
                    _context.SaveChanges();
                    var modifire_price = new MODIFIRE_PRICE();
                    modifire_price.ModifireID   = new_data.ModifireID;
                    modifire_price.CurrentPrice = data.CurrentPrice;
                    modifire_price.CreateBy     = data.CreateBy ?? 0;
                    modifire_price.CreateDate   = DateTime.Now;
                    modifire_price.UpdateBy     = data.UpdateBy ?? 0;
                    modifire_price.UpdateDate   = DateTime.Now;
                    modifire_price.Note         = data.Note ?? "";
                    var result = CreatedModifirePrice(modifire_price);
                    return(result);
                }
                else
                {
                    var checkdata = _context.MODIFIREs.Where(x => x.ModifireName == data.ModifireName && x.ModifireID != data.ModifireID).ToList();
                    if (checkdata.Count() > 0)
                    {
                        return(-1);
                    }
                    var old_data = _context.MODIFIREs.Find(data.ModifireID);
                    if (old_data != null)
                    {
                        old_data.ModifireName = data.ModifireName;
                        old_data.Color        = data.Color ?? "";
                        old_data.Status       = 1;
                        old_data.UpdateBy     = data.UpdateBy ?? 0;
                        old_data.UpdateDate   = DateTime.Now;
                        old_data.Note         = data.Note ?? "";

                        _context.Entry(old_data).State = EntityState.Modified;
                        _context.SaveChanges();
                        var modifire_price = new MODIFIRE_PRICE();
                        modifire_price.ModifireID   = data.ModifireID;
                        modifire_price.CurrentPrice = data.CurrentPrice;
                        modifire_price.CreateBy     = data.CreateBy ?? 0;
                        modifire_price.CreateDate   = DateTime.Now;
                        modifire_price.UpdateBy     = data.UpdateBy ?? 0;
                        modifire_price.UpdateDate   = DateTime.Now;
                        modifire_price.Note         = data.Note ?? "";
                        var result = CreatedModifirePrice(modifire_price);
                        return(result);
                    }
                    return(0);
                }
            }
            catch (Exception)
            {
                return(0);
            }
        }