Exemplo n.º 1
0
        // Sau khi nhấn thanh toán EditBill (thêm thời gian checkout, đổi "chưa thanh toán" sang "đã thanh toán"). Sau đó chỉnh sửa ở bảng TblTable (change Status từ "trống" sang "có khách")
        public void EditBill(int BillID, int TableID, string Status, DateTime?TimCheckOut, double TotalBill)
        {
            TblBill bill = new TblBill();

            bill              = data.TblBills.Single(n => n.ID == BillID);
            bill.TableID      = TableID;
            bill.BillStatus   = Status;
            bill.DateCheckOut = TimCheckOut;
            bill.TotalBill    = TotalBill;
            data.SaveChanges();
        }
Exemplo n.º 2
0
        // Kiểm tra Bill đã tồn tại chưa ( input là TableID condition:"chưa thanh toán")
        public bool IsBillExists(int TableID)
        {
            TblBill bill = new TblBill();

            if (data.TblBills.Where(n => n.TableID == TableID && n.BillStatus == "Chưa thanh toán").Count() == 0)
            {
                return(false); // chưa tồn tại
            }
            else
            {
                return(true);
            }
        }
Exemplo n.º 3
0
        // Nếu Bill chưa tồn tại thì tạo mới Bill. Sau đó chỉnh sửa ở bảng TblTable (change Status từ "trống" sang "có khách")
        public void AddNewBill(int TableID, string Status, DateTime TimeCheckIn, DateTime?TimCheckOut, double TotalBill)
        {
            TblBill newBill = new TblBill()
            {
                TableID      = TableID,
                BillStatus   = Status,
                DateCheckIn  = TimeCheckIn,
                DateCheckOut = TimCheckOut,
                TotalBill    = TotalBill
            };

            data.TblBills.Add(newBill);
            data.SaveChanges();
        }
Exemplo n.º 4
0
        public void ImportDBProcess()
        {
            string tableName = "";
            //string root = Android.OS.Environment.DirectoryDownloads;
            var enggine = new FileHelperAsyncEngine <FileHelperModel>();

            //System.IO.DirectoryNotFoundException: 'Could not find a part of the path "/content:/com.android.providers.downloads.documents/document/21"

            //using (enggine.BeginReadFile(fileData.FilePath))
            //using (enggine.BeginReadFile(DependencyService.Get<IFileHelper>().GetLocalDownloadPath(fileData.FileName)))
            //using (enggine.BeginReadFile(System.IO.Path.Combine(FileSystem.AppDataDirectory, "DataImport.csv")))
            //using (enggine.BeginReadFile(DependencyService.Get<IFileHelper>().GetLocalFilePath("DataImport.csv")))
            using (enggine.BeginReadFile(filePath.Text))
            {
                List <TblInventory>    tblInventory    = new List <TblInventory>();
                List <TblDISCNT_ITEM>  tblDISCNT_ITEM  = new List <TblDISCNT_ITEM>();
                List <TblBill>         tblBill         = new List <TblBill>();
                List <TblSold_Item>    tblSold_Item    = new List <TblSold_Item>();
                List <TblStok_History> tblStok_History = new List <TblStok_History>();

                foreach (FileHelperModel fileHlp in enggine)
                {
                    if (fileHlp.ID_BRG.StartsWith("#TABLE:"))
                    {
                        if (tableName == "")
                        {
                            tableName = fileHlp.ID_BRG.Replace("#TABLE:", "");
                        }
                        else
                        {
                            if (tableName == "INVENTORY")
                            {
                                App.arPosRepo.InsertInvAllSync(tblInventory);
                            }
                            if (tableName == "DISCNT_ITEM")
                            {
                                App.arPosRepo.InsertInvAllSync(tblDISCNT_ITEM);
                            }
                            if (tableName == "BILL")
                            {
                                App.arPosRepo.InsertInvAllSync(tblBill);
                            }
                            if (tableName == "SOLD_ITEM")
                            {
                                App.arPosRepo.InsertInvAllSync(tblSold_Item);
                            }
                            if (tableName == "STOK_HISTORY")
                            {
                                App.arPosRepo.InsertInvAllSync(tblStok_History);
                            }
                            tableName = fileHlp.ID_BRG.Replace("#TABLE:", "");
                        }
                    }
                    else
                    {
                        if (tableName == "INVENTORY")
                        {
                            TblInventory barTblInventory = new TblInventory();
                            barTblInventory.ID_BRG   = fileHlp.ID_BRG;
                            barTblInventory.NM_BRG   = fileHlp.NM_BRG;
                            barTblInventory.STOK_MIN = fileHlp.STOK_MIN;
                            if (fileHlp.EXP_TGL.ToString() != "")
                            {
                                barTblInventory.EXP_TGL = DateTime.Parse(fileHlp.EXP_TGL.ToString());
                            }

                            barTblInventory.SATUAN = fileHlp.SATUAN;
                            if (fileHlp.SATUAN_JUAL.ToString() != "")
                            {
                                barTblInventory.SATUAN_JUAL = int.Parse(fileHlp.SATUAN_JUAL.ToString());
                            }
                            if (fileHlp.HRG_MODAL.ToString() != "")
                            {
                                barTblInventory.HRG_MODAL = int.Parse(fileHlp.HRG_MODAL.ToString());
                            }
                            if (fileHlp.HRG_JUAL.ToString() != "")
                            {
                                barTblInventory.HRG_JUAL = int.Parse(fileHlp.HRG_JUAL.ToString());
                            }
                            if (fileHlp.STOK.ToString() != "")
                            {
                                barTblInventory.STOK = int.Parse(fileHlp.STOK.ToString());
                            }

                            barTblInventory.OWNER = fileHlp.OWNER;
                            if (fileHlp.LAST_TRN.ToString() != "")
                            {
                                barTblInventory.LAST_TRN = DateTime.Parse(fileHlp.LAST_TRN.ToString());
                            }


                            tblInventory.Add(barTblInventory);
                        }
                        else if (tableName == "DISCNT_ITEM")
                        {
                            TblDISCNT_ITEM barTblDIS = new TblDISCNT_ITEM();
                            barTblDIS.ID_BRG     = fileHlp.ID_BRG;
                            barTblDIS.KETERANGAN = fileHlp.NM_BRG;
                            barTblDIS.QTY        = fileHlp.STOK_MIN;

                            if (fileHlp.HRG_MODAL.ToString() != "")
                            {
                                barTblDIS.HRG_DIS_SATUAN = int.Parse(fileHlp.HRG_MODAL.ToString());
                            }

                            tblDISCNT_ITEM.Add(barTblDIS);
                        }
                        else if (tableName == "BILL")
                        {
                            TblBill barTblBil = new TblBill();
                            barTblBil.BIL_NO      = Convert.ToInt32(fileHlp.ID_BRG);
                            barTblBil.NM_PEL      = fileHlp.NM_BRG;
                            barTblBil.UANG_TERIMA = fileHlp.STOK_MIN;
                            if (fileHlp.EXP_TGL.ToString() != "")
                            {
                                barTblBil.BIL_TGL = DateTime.Parse(fileHlp.EXP_TGL.ToString());
                            }

                            barTblBil.JENIS_BAYAR = fileHlp.SATUAN;
                            if (fileHlp.SATUAN_JUAL.ToString() != "")
                            {
                                barTblBil.SPCL_DISC = int.Parse(fileHlp.SATUAN_JUAL.ToString());
                            }
                            if (fileHlp.HRG_MODAL.ToString() != "")
                            {
                                barTblBil.UANG_KEMBALI = int.Parse(fileHlp.HRG_MODAL.ToString());
                            }
                            if (fileHlp.HRG_JUAL.ToString() != "")
                            {
                                barTblBil.BAYAR_LAIN = int.Parse(fileHlp.HRG_JUAL.ToString());
                            }
                            barTblBil.OPRBY = fileHlp.OWNER;
                            if (fileHlp.LAST_TRN.ToString() != "")
                            {
                                barTblBil.KAS_TGL = DateTime.Parse(fileHlp.LAST_TRN.ToString());
                            }

                            tblBill.Add(barTblBil);
                        }
                        else if (tableName == "SOLD_ITEM")
                        {
                            TblSold_Item barTblSold = new TblSold_Item();
                            barTblSold.BIL_NO = Convert.ToInt32(fileHlp.ID_BRG);
                            barTblSold.ID_BRG = fileHlp.NM_BRG;
                            barTblSold.QTY    = fileHlp.STOK_MIN;

                            barTblSold.NM_BRG = fileHlp.SATUAN;
                            if (fileHlp.SATUAN_JUAL.ToString() != "")
                            {
                                barTblSold.HRG_SATUAN = int.Parse(fileHlp.SATUAN_JUAL.ToString());
                            }
                            if (fileHlp.HRG_MODAL.ToString() != "")
                            {
                                barTblSold.HRG_TOTAL = int.Parse(fileHlp.HRG_MODAL.ToString());
                            }
                            if (fileHlp.HRG_JUAL.ToString() != "")
                            {
                                barTblSold.DISCOUNT = int.Parse(fileHlp.HRG_JUAL.ToString());
                            }
                            if (fileHlp.STOK.ToString() != "")
                            {
                                barTblSold.HRG_MODAL = int.Parse(fileHlp.STOK.ToString());
                            }
                            barTblSold.UNIT     = fileHlp.OWNER;
                            barTblSold.DISC_KET = fileHlp.DISC_KET;
                            if (fileHlp.PROFIT.ToString() != "")
                            {
                                barTblSold.PROFIT = int.Parse(fileHlp.PROFIT.ToString());
                            }
                            if (fileHlp.PEMBULATAN.ToString() != "")
                            {
                                barTblSold.PEMBULATAN = int.Parse(fileHlp.PEMBULATAN.ToString());
                            }

                            tblSold_Item.Add(barTblSold);
                        }
                        else if (tableName == "STOK_HISTORY")
                        {
                            TblStok_History barTblSHis = new TblStok_History();
                            barTblSHis.ID_BRG    = fileHlp.ID_BRG;
                            barTblSHis.KET       = fileHlp.NM_BRG;
                            barTblSHis.STOK_AWAL = fileHlp.STOK_MIN;
                            if (fileHlp.EXP_TGL.ToString() != "")
                            {
                                barTblSHis.TGL = DateTime.Parse(fileHlp.EXP_TGL.ToString());
                            }
                            if (fileHlp.SATUAN_JUAL.ToString() != "")
                            {
                                barTblSHis.STOK_ADD = int.Parse(fileHlp.SATUAN_JUAL.ToString());
                            }
                            if (fileHlp.HRG_MODAL.ToString() != "")
                            {
                                barTblSHis.STOK_AKHIR = int.Parse(fileHlp.HRG_MODAL.ToString());
                            }
                            barTblSHis.OPRBY = fileHlp.OWNER;

                            tblStok_History.Add(barTblSHis);
                        }
                    }
                }

                //Insert untuk jika habis
                if (tableName == "INVENTORY")
                {
                    App.arPosRepo.InsertInvAllSync(tblInventory);
                }
                if (tableName == "DISCNT_ITEM")
                {
                    App.arPosRepo.InsertInvAllSync(tblDISCNT_ITEM);
                }
                if (tableName == "BILL")
                {
                    App.arPosRepo.InsertInvAllSync(tblBill);
                }
                if (tableName == "SOLD_ITEM")
                {
                    App.arPosRepo.InsertInvAllSync(tblSold_Item);
                }
                if (tableName == "STOK_HISTORY")
                {
                    App.arPosRepo.InsertInvAllSync(tblStok_History);
                }
            }
        }