Exemplo n.º 1
0
        public JsonResult getGridStockControl(string sEcho, int iDisplayStart, int iDisplayLength)
        {
            var msgTotalTransactions = new Dominio.Mensagens.Filtro.Stock();

            msgTotalTransactions.iDisplayStart  = iDisplayStart;
            msgTotalTransactions.iDisplayLength = iDisplayLength;
            //msgTotalTransactions.Report_Type = Convert.ToInt32(Request["cmbReport_Type"]);
            //msgTotalTransactions.dtInicio = Convert.ToString(Request["txtDtInicio"]);
            //msgTotalTransactions.dtFim = Convert.ToString(Request["txtDtFim"]);
            //msgTotalTransactions.txtNome = Convert.ToString(Request["txtNome"]);

            var displayedCompanies = Fachada.Repositorio.STOCK.GetAllStockControlByFilter(msgTotalTransactions);

            var result = (from c in displayedCompanies.Instances
                          select new[] {
                UtilsLibrary.GetListEnum(typeof(TabProduct_Type)).Where(w => w.StringValue == c.Description.ToString()).Select(s => s.StringDescription).FirstOrDefault(),
                c.Amount.ToString()
            }).Take(iDisplayLength);

            return(Json(new
            {
                sEcho = sEcho,                                  // Variável Padraão do plugin
                iTotalRecords = 50,                             // Deve realizar outra pesquisa no Banco de Daods sem Filtro de pesquisa e mostar a quantidade de registros no Banco nessa variável "iTotalRecords" no exemplo esta 1000 fixo mas deve ser a qtde total de registro que existe na tabela
                iTotalDisplayRecords = displayedCompanies.Code, //Total de Registro com filtro  Aplicado
                aaData = result                                 // Lista que será exibida do grid
            }, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 2
0
        public PdfPTable createTableEndOfTheDay(List <Dominio.Mensagens.GridTotalTransactionIndex> collection, decimal totalEndOfTheDay)
        {
            PdfPTable table = new PdfPTable(9);

            table.TotalWidth  = 560f;
            table.LockedWidth = true;

            //relative col widths in proportions - 1/3 and 2/3
            float[] widths = new float[] { 5f, 4f, 4f, 5f, 5f, 5f, 5f, 6f, 3f };
            table.SetWidths(widths);
            table.HorizontalAlignment = 0;
            //leave a gap before and after the table
            table.SpacingBefore = 20f;
            //table.SpacingAfter = 10f;

            Font fontTitle = new Font(Font.FontFamily.TIMES_ROMAN, 10f, Font.BOLD);
            Font font      = new Font(Font.FontFamily.TIMES_ROMAN, 9f, Font.NORMAL);

            PdfPCell cell = new PdfPCell();

            cell.Colspan             = 9;
            cell.HorizontalAlignment = 1; //0=Left, 1=Centre, 2=Right
            table.AddCell(cell);

            table.AddCell(new Phrase("Day Month Year Reference", fontTitle));
            table.AddCell(new Phrase("Shift", fontTitle));
            table.AddCell(new Phrase("User", fontTitle));
            table.AddCell(new Phrase("Total Transactions", fontTitle));
            table.AddCell(new Phrase("Total Last Cashier", fontTitle));
            table.AddCell(new Phrase("Total Final", fontTitle));
            table.AddCell(new Phrase("Total Calculator", fontTitle));
            table.AddCell(new Phrase("Difference between Cashier and Calculator", fontTitle));
            table.AddCell(new Phrase("Report Type", fontTitle));

            foreach (var item in collection)
            {
                table.AddCell(new Phrase(item.DAY_MONTH_YEAR_REFERENCE.Value.ToString("dd/MM/yyyy"), font));
                table.AddCell(new Phrase(UtilsLibrary.GetListEnum(typeof(TabSHIFT_TYPE)).Where(w => w.Value == item.ID_SHIFT_TYPE.ToString()).Select(s => s.StringDescription).FirstOrDefault(), font));
                table.AddCell(new Phrase(item.LogLogin, font));
                table.AddCell(new Phrase(item.TotalTransactions.ToString("C2"), font));
                table.AddCell(new Phrase(item.LastTotalCashier.ToString("C2"), font));
                table.AddCell(new Phrase(item.TotalFinal.ToString("C2"), font));
                table.AddCell(new Phrase(item.TotalCalc.ToString("C2"), font));
                table.AddCell(new Phrase(item.DifferenceFinalCalc.ToString("C2"), font));
                table.AddCell(new Phrase(UtilsLibrary.GetListEnum(typeof(TabReport_Type)).Where(w => w.Value == item.ID_Report_Type.ToString()).Select(s => s.StringDescription).FirstOrDefault(), font));
            }

            table.AddCell(new Phrase(string.Empty));
            table.AddCell(new Phrase(string.Empty));
            table.AddCell(new Phrase("Total: ", fontTitle));
            table.AddCell(new Phrase(totalEndOfTheDay.ToString("C2"), font));
            table.AddCell(new Phrase(string.Empty));
            table.AddCell(new Phrase(string.Empty));
            table.AddCell(new Phrase(string.Empty));
            table.AddCell(new Phrase(string.Empty));
            table.AddCell(new Phrase(string.Empty));

            return(table);
        }
Exemplo n.º 3
0
        // GET: AtoAposentadoria/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            carregaCombos();

            var msg = Fachada.Repositorio.MONEY_COUNT.GetMoney_CountDetailsByID(id.Value);

            if (msg.Result != Message.ResultType.Success)
            {
                return(Content(msg.Description));
            }
            if (msg.Instance == null)
            {
                return(HttpNotFound());
            }

            TelaCalc calcView = new TelaCalc();

            calcView.DescriptionCalcType = UtilsLibrary.GetListEnum(typeof(TabCalc_Type)).Where(w => w.Value == msg.Instance.IDCalc_Type.ToString()).Select(s => s.StringDescription).FirstOrDefault();
            calcView.LogLogin            = msg.Instance.LogLogin;
            calcView.TotalCalc           = msg.Instance.TotalCalc;
            calcView.IDMoney_Count       = msg.Instance.IDMoney_Count;
            calcView.Qnt_1_Cent          = msg.Instance.Qnt_1_Cent;
            calcView.Qnt_2_Cents         = msg.Instance.Qnt_2_Cents;
            calcView.Qnt_5_Cents         = msg.Instance.Qnt_5_Cents;
            calcView.Qnt_10_Cents        = msg.Instance.Qnt_10_Cents;
            calcView.Qnt_20_Cents        = msg.Instance.Qnt_20_Cents;
            calcView.Qnt_50_Cents        = msg.Instance.Qnt_50_Cents;
            calcView.Qnt_1_Euro          = msg.Instance.Qnt_1_Euro;
            calcView.Qnt_2_Euros         = msg.Instance.Qnt_2_Euros;
            calcView.Qnt_5_Euros         = msg.Instance.Qnt_5_Euros;
            calcView.Qnt_10_Euros        = msg.Instance.Qnt_10_Euros;
            calcView.Qnt_20_Euros        = msg.Instance.Qnt_20_Euros;
            calcView.Qnt_50_Euros        = msg.Instance.Qnt_50_Euros;
            calcView.Qnt_100_Euros       = msg.Instance.Qnt_100_Euros;
            calcView.Qnt_200_Euros       = msg.Instance.Qnt_200_Euros;
            calcView.Qnt_500_Euros       = msg.Instance.Qnt_500_Euros;
            calcView.TotalMoney_Count    = msg.Instance.TotalMoney_Count;
            calcView.DT_Reg = msg.Instance.DT_Reg;

            return(View(calcView));
        }
Exemplo n.º 4
0
        public ActionResult IndexByTotalTransactions(int?id, int idTransaction, string returnAction, string returnController)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            carregaCombos();

            List <GridMoney_Count> listGridMoney = new List <GridMoney_Count>();

            var displayedCompanies = Fachada.Repositorio.MONEY_COUNT.GetMoney_CountByID_Calc(id.Value);

            foreach (var item in displayedCompanies.Instances)
            {
                GridMoney_Count calcView = new GridMoney_Count();
                calcView.DescriptionCalcType = UtilsLibrary.GetListEnum(typeof(TabCalc_Type)).Where(w => w.Value == item.IDCalc_Type.ToString()).Select(s => s.StringDescription).FirstOrDefault();
                calcView.LogLogin            = item.LogLogin;
                calcView.TotalCalc           = item.TotalCalc;
                calcView.IDMoney_Count       = item.IDMoney_Count;
                calcView.Qnt_1_Cent          = item.Qnt_1_Cent;
                calcView.Qnt_2_Cents         = item.Qnt_2_Cents;
                calcView.Qnt_5_Cents         = item.Qnt_5_Cents;
                calcView.Qnt_10_Cents        = item.Qnt_10_Cents;
                calcView.Qnt_20_Cents        = item.Qnt_20_Cents;
                calcView.Qnt_50_Cents        = item.Qnt_50_Cents;
                calcView.Qnt_1_Euro          = item.Qnt_1_Euro;
                calcView.Qnt_2_Euros         = item.Qnt_2_Euros;
                calcView.Qnt_5_Euros         = item.Qnt_5_Euros;
                calcView.Qnt_10_Euros        = item.Qnt_10_Euros;
                calcView.Qnt_20_Euros        = item.Qnt_20_Euros;
                calcView.Qnt_50_Euros        = item.Qnt_50_Euros;
                calcView.Qnt_100_Euros       = item.Qnt_100_Euros;
                calcView.Qnt_200_Euros       = item.Qnt_200_Euros;
                calcView.Qnt_500_Euros       = item.Qnt_500_Euros;
                calcView.TotalMoney_Count    = item.TotalMoney_Count;
                calcView.DT_Reg = item.DT_Reg;
                listGridMoney.Add(calcView);
            }
            ViewBag.TotalCalc = GetTotalToCalc();

            return(View(listGridMoney));
        }
Exemplo n.º 5
0
        public JsonResult getGridTransaction(string sEcho, int iDisplayStart, int iDisplayLength, string sSortDir_0, int iSortCol_0)
        {
            var msgTotalTransactions = new Dominio.Mensagens.Filtro.TotalTransactions();

            msgTotalTransactions.iDisplayStart  = iDisplayStart;
            msgTotalTransactions.iDisplayLength = iDisplayLength;
            msgTotalTransactions.sSortDir_0     = "desc";// sSortDir_0;
            msgTotalTransactions.iSortCol_0     = iSortCol_0;
            msgTotalTransactions.Report_Type    = Convert.ToInt32(Request["cmbReport_Type"]);
            msgTotalTransactions.dtInicio       = Convert.ToString(Request["txtDtInicio"]);
            msgTotalTransactions.dtFim          = Convert.ToString(Request["txtDtFim"]);
            msgTotalTransactions.txtNome        = Convert.ToString(Request["txtNome"]);
            msgTotalTransactions.ID_REPORT_TYPE = (int)TabReport_Type.Bank;

            var displayedCompanies = Fachada.Repositorio.TOTAL_TRANSACTIONS.GetAllTotalTransactions(msgTotalTransactions);

            var result = (from c in displayedCompanies.Instances
                          select new[] {
                c.ID.ToString(),
                c.DT_Reg.ToString(),
                UtilsLibrary.GetListEnum(typeof(TabSHIFT_TYPE)).Where(w => w.Value == c.ID_SHIFT_TYPE.ToString()).Select(s => s.StringDescription).FirstOrDefault(),
                c.LogLogin,
                c.TotalTransactions.ToString("C2"),
                c.LastTotalCashier.ToString("C2"),
                c.TotalFinal.ToString("C2"),
                c.TotalCalc.ToString("C2"),
                c.DifferenceFinalCalc.ToString("C2"),
                UtilsLibrary.GetListEnum(typeof(TabReport_Type)).Where(w => w.Value == c.ID_Report_Type.ToString()).Select(s => s.StringDescription).FirstOrDefault(),
            }).Take(iDisplayLength);

            return(Json(new
            {
                sEcho = sEcho,                                  // Variável Padraão do plugin
                iTotalRecords = 50,                             // Deve realizar outra pesquisa no Banco de Daods sem Filtro de pesquisa e mostar a quantidade de registros no Banco nessa variável "iTotalRecords" no exemplo esta 1000 fixo mas deve ser a qtde total de registro que existe na tabela
                iTotalDisplayRecords = displayedCompanies.Code, //Total de Registro com filtro  Aplicado
                aaData = result                                 // Lista que será exibida do grid
            }, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 6
0
        public ActionResult Create([Bind(Include = "cmbReport_Type, txtCopied")] Dominio.Mensagens.TelaTransactions transaction)
        {
            if (ModelState.IsValid)
            {
                string  txtCopied = Convert.ToString(Request["txtCopied"]);
                decimal txtTotalLastCashierVagner = 0;
                if (!string.IsNullOrEmpty(Request["TotalLastCashierVagner"]))
                {
                    txtTotalLastCashierVagner = Convert.ToDecimal(Request["TotalLastCashierVagner"]);
                }

                decimal            totalLastEnvelope = 0, totalTransactions = 0;
                int                idLastCalc = 0;
                List <Transaction> listTrans  = new List <Transaction>();

                var lsTabTransaction = UtilsLibrary.GetListEnum(typeof(TabTransaction_Type));
                var lsTabPayment     = UtilsLibrary.GetListEnum(typeof(TabPayment_Type));

                foreach (string row in txtCopied.Split(new String[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries))
                {
                    int         i     = 0;
                    Transaction trans = new Transaction();
                    if (!string.IsNullOrEmpty(row))
                    {
                        foreach (string cell in row.Split('\t'))
                        {
                            if (i == 0)
                            {
                                trans.DT_Reg = Convert.ToDateTime(cell);
                            }
                            else if (i == 1)
                            {
                                trans.DT_Reg = trans.DT_Reg.AddHours(Convert.ToDateTime(cell).Hour).AddMinutes(Convert.ToDateTime(cell).Minute).AddSeconds(Convert.ToDateTime(cell).Second);
                            }
                            else if (i == 2)
                            {
                                trans.LogLogin = cell;
                            }
                            else if (i == 3)
                            {
                                trans.Reservation_Number = cell;
                            }
                            else if (i == 4)
                            {
                                trans.GuestName = cell;
                            }
                            else if (i == 5)
                            {
                                if (!string.IsNullOrEmpty(cell))
                                {
                                    trans.ID_Transaction_Type = Convert.ToInt32(lsTabTransaction.Where(w => w.StringDescription.Trim().ToUpper() == cell.Trim().ToUpper()).Select(s => s.StringValue).FirstOrDefault());
                                }
                            }
                            else if (i == 6)
                            {
                                if (!string.IsNullOrEmpty(cell))
                                {
                                    trans.ID_Payment_Type = Convert.ToInt32(lsTabPayment.Where(w => w.StringDescription.Trim().ToUpper() == cell.Trim().ToUpper()).Select(s => s.StringValue).FirstOrDefault());
                                }
                                i++;
                            }
                            else if (i == 8)
                            {
                                trans.Description = cell;
                            }
                            else if (i == 9)
                            {
                                string[] totalT = cell.Split('€');
                                if (totalT[0].Contains("-"))
                                {
                                    trans.Total = Convert.ToDecimal("-" + totalT[1].Trim());
                                }
                                else if (totalT[0].Contains("("))
                                {
                                    trans.Total = Convert.ToDecimal("-" + totalT[1].Trim().Split(')')[0]);
                                }
                                else
                                {
                                    trans.Total = Convert.ToDecimal(totalT[1].Trim());
                                }

                                totalTransactions += trans.Total;
                            }
                            i++;
                        }
                        listTrans.Add(trans);
                    }
                }

                var msgTotalLastCalc = Fachada.Repositorio.CALC.GetTotalLastCalc();
                if (msgTotalLastCalc != null)
                {
                    idLastCalc = msgTotalLastCalc.Instance.ID;
                }

                var totalTransaction = new Total_Transactions();
                totalTransaction.ID_Report_Type = (int)TabReport_Type.Bank;

                var msgEnvelope = Fachada.Repositorio.MONEY_COUNT.GetLastMoney_CountByIdCalcType((int)TabCalc_Type.Envelope);
                if (msgEnvelope != null)
                {
                    totalLastEnvelope = msgEnvelope.Instance.Total;
                }

                totalTransaction.Last_Cashier_Total = txtTotalLastCashierVagner;
                totalTransaction.TotalTransactions  = totalTransactions;
                totalTransaction.TotalFinal         = (totalTransactions + txtTotalLastCashierVagner) - totalLastEnvelope;
                totalTransaction.LogLogin           = (User != null && User.Identity != null && !string.IsNullOrEmpty(User.Identity.Name)) ? User.Identity.Name : string.Empty;
                totalTransaction.DT_Reg             = DateTime.UtcNow;
                totalTransaction.ID_Calc            = idLastCalc;


                var msgSaveTotal_Transactions = Fachada.Negocio.ManterTOTAL_TRANSACTIONS.Salvar(totalTransaction);
                if (msgSaveTotal_Transactions.Result != Message.ResultType.Success)
                {
                    return(Content(msgSaveTotal_Transactions.Description));
                }

                foreach (var item in listTrans)
                {
                    item.ID_Total_Transactions = totalTransaction.ID;
                }

                var msgSaveTransactions = Fachada.Negocio.ManterTRANSACTIONS.SaveList(listTrans.ToArray());
                if (msgSaveTransactions.Result != Message.ResultType.Success)
                {
                    return(Content(msgSaveTransactions.Description));
                }

                return(RedirectToAction("Details", "Bank", new { id = totalTransaction.ID }));
            }

            return(View(transaction));
        }
Exemplo n.º 7
0
        public ActionResult CreateVerifyBooking([Bind(Include = "")] Total_Transactions transaction)
        {
            if (ModelState.IsValid)
            {
                string txtCopied = Convert.ToString(Request["txtCopied"]);
                int    txtDays   = Convert.ToInt32(Request["txtDays"]);


                int         cmbReport_Type    = Convert.ToInt32(Request["cmbReport_Type"]);
                decimal     totalTransactions = 0;
                var         listStocks        = new List <Camada.Dominio.Entidades.Stock>();
                List <LIST> listLITS          = new List <LIST>();
                string[]    splitTxtCopied    = txtCopied.Split(new String[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries);
                int         countSplit        = 0;
                DateTime    dtTest            = DateTime.Now;
                LIST        list = new LIST();

                foreach (string row in splitTxtCopied)
                {
                    if (countSplit == 0 && DateTime.TryParse(row, out dtTest))
                    {
                        countSplit++;
                        continue;
                    }
                    else if (countSplit == 0)
                    {
                        continue;
                    }
                    if (countSplit == 2 ||
                        countSplit == 3)
                    {
                        countSplit++;
                        continue;
                    }

                    int i = 0;
                    if (!string.IsNullOrEmpty(row))
                    {
                        string[] splitRow = row.Split('\t');
                        if (splitRow.Count() > 1)
                        {
                            foreach (string cell in splitRow)
                            {
                                if (i == 1)
                                {
                                    list.CHECK_IN = Convert.ToDateTime(cell);
                                }
                                else if (i == 2)
                                {
                                    list.CHECK_OUT = Convert.ToDateTime(cell);
                                    listLITS.Add(list);
                                    list = new LIST();
                                }
                                i++;
                            }
                        }
                        else
                        {
                            if (countSplit == 1)
                            {
                                list.FIRST_NAME_GUEST = row.Split(',')[0];
                                list.LAST_NAME_GUEST  = row.Split(',')[1];
                            }
                        }
                    }
                    countSplit++;
                    if (countSplit >= 4)
                    {
                        countSplit = 0;
                    }
                }

                int totalDifference = 0;
                foreach (var item in listLITS)
                {
                    int aux = (item.CHECK_OUT.Value - item.CHECK_IN.Value).Days;
                    if (aux < 0)
                    {
                        aux = (item.CHECK_OUT.Value.AddYears(1) - item.CHECK_IN.Value).Days;
                    }
                    totalDifference += aux;
                }

                if (totalDifference > txtDays)
                {
                    list = new LIST();
                    list.DT_START_BLOCK   = listLITS.OrderByDescending(o => o.CHECK_OUT).FirstOrDefault().CHECK_OUT;
                    list.DT_START_BOOK    = list.DT_START_BLOCK.Value.AddMonths(1);
                    list.FIRST_NAME_GUEST = listLITS.FirstOrDefault().FIRST_NAME_GUEST;
                    list.LAST_NAME_GUEST  = listLITS.FirstOrDefault().LAST_NAME_GUEST;
                    list.ID_LIST_TYPE     = Convert.ToInt32(UtilsLibrary.GetListEnum(typeof(TabList_Type)).Where(w => w.Name == TabList_Type.VERIFY_BOOKING.ToString()).Select(s => s.StringValue).FirstOrDefault());
                    list.LOGLOGIN         = User.Identity.Name;

                    var msgSaveList = Fachada.Negocio.ManterLIST.Save(list);
                    if (msgSaveList.Result != Message.ResultType.Success)
                    {
                        return(Content(msgSaveList.Description));
                    }

                    return(RedirectToAction("EditVerifyBooking", "LISTS", new { id = list.ID, uploadImage = true }));
                }
                else
                {
                    return(RedirectToAction("CreateVerifyBooking", "LISTS", new { msg = "Guest encontra-se dentro do limite dos " + txtDays + " Dias" }));
                }
            }
            return(View());
        }
Exemplo n.º 8
0
        MessageCollection <GridAtosPessoalConsulta> ICALC.GetAllCalcByFilter(Dominio.Mensagens.Filtro.Calc filtroPesquisa)
        {
            var msg = new MessageCollection <Dominio.Mensagens.GridAtosPessoalConsulta>();

            try
            {
                using (var context = new HostelEntities())
                {
                    var    enumTabTipoSolicitacao = UtilsLibrary.GetListEnum(typeof(TabTipoSolicitacao));
                    string ssa = enumTabTipoSolicitacao.Where(w => w.Value == "6").Select(s => s.StringTabTipoSolicitacao).FirstOrDefault();
                    ////Não pode ser feito o .ToList nesse momento, a query SQL esta esta sendo montada de acordo com os filtros
                    var query = (from c in context.Calcs
                                 //join ct in context.Calc_Type on c.ID_Calc_Type equals ct.ID
                                 //join mc in context.Money_Count on c.ID_Money_Count equals mc.ID

                                 //join s in context.V_SFI_Servidor on a.identificadorSFI_Servidor equals s.identificador
                                 //join soli in context.V_SV_Solicitacao on a.identificador_Solicitacao equals soli.identificador
                                 //join apo in context.AP_APOSENTADORIA on a.identificador equals apo.identificador

                                 //join soli in context.V_SV_Solicitacao on a.identificador_Solicitacao equals soli.identificador into soliLeft
                                 //join apo in context.AP_APOSENTADORIA on a.identificador equals apo.identificador into apoLeft
                                 //from subSoli in soliLeft.DefaultIfEmpty()
                                 //from subApo in apoLeft.DefaultIfEmpty()
                                 //where a.identificador_Solicitacao != null
                                 select new Dominio.Mensagens.GridCalc()
                    {
                        ID = c.ID,
                        DT_reg = c.DT_reg,
                        //Calc_Type = ct.Description.ToString(),
                        LogLogin = c.LogLogin,
                        Total = c.Total.ToString()
                                //identificador = a.identificador,
                                // nome = s.nomeServidor,
                                // dtCadastro = (subApo != null && subApo.dataEnvioAposentadoria.HasValue && !string.IsNullOrEmpty(subApo.dataEnvioAposentadoria.Value.ToString()) ? subApo.dataEnvioAposentadoria.Value.ToString() : string.Empty),
                                // Estado = a.numeroProcesso.HasValue ? "Ato Enviado" : "Ato Não Enviado",
                                // numeroProcesso = a.numeroProcesso.ToString(),
                                // TipoAtoPessoal = (subSoli == null ? a.identificadorTAB_TipoAtoPessoal.Value.ToString() : subSoli.identificadorSV_TabTipoSolicitacao.Value.ToString()),
                                // CPF = s.numeroCpf.ToString(),
                                // unidadeGestora = a.identificadorUnidadeGestora
                    });

                    //Filtros de Pesquisa
                    //if (!string.IsNullOrEmpty(filtroPesquisa.nome))
                    //    query = query.Where(q => q.nome.Trim().ToUpper().Contains(filtroPesquisa.nome.Trim().ToUpper()));

                    //if (!string.IsNullOrEmpty(filtroPesquisa.numeroProcesso))
                    //    query = query.Where(q => q.numeroProcesso == filtroPesquisa.numeroProcesso);

                    //if (filtroPesquisa.Estado == 0)
                    //    query = query.Where(q => string.IsNullOrEmpty(q.numeroProcesso));
                    //else //(filtroPesquisa.Estado == 0)
                    //    query = query.Where(q => !string.IsNullOrEmpty(q.numeroProcesso));

                    //if (filtroPesquisa.TipoAtoPessoal > 0)
                    //    query = query.Where(q => q.TipoAtoPessoal == filtroPesquisa.TipoAtoPessoal.ToString());

                    //if (!string.IsNullOrEmpty(filtroPesquisa.CPF))
                    //    query = query.Where(q => q.CPF == filtroPesquisa.CPF);

                    //if (!string.IsNullOrEmpty(filtroPesquisa.dtInicio))
                    //{
                    //    DateTime dtFim = DateTime.Now;
                    //    if (string.IsNullOrEmpty(filtroPesquisa.dtFim))
                    //        dtFim = Convert.ToDateTime(filtroPesquisa.dtFim);

                    //    query = query.Where(q => (Convert.ToDateTime(q.dtCadastro) >= Convert.ToDateTime(filtroPesquisa.dtInicio) && Convert.ToDateTime(q.dtCadastro) <= dtFim));
                    //}

                    //if (filtroPesquisa.unidade > 0)
                    //    query = query.Where(q => q.unidadeGestora == filtroPesquisa.unidade);

                    //ordenação
                    if (filtroPesquisa.sSortDir_0 == "asc")
                    {
                        if (filtroPesquisa.iSortCol_0 == 1)
                        {
                            query = query.OrderBy(q => q.ID);
                        }
                        else if (filtroPesquisa.iSortCol_0 == 2)
                        {
                            query = query.OrderBy(q => q.DT_reg);
                        }
                        else if (filtroPesquisa.iSortCol_0 == 3)
                        {
                            query = query.OrderBy(q => q.Calc_Type);
                        }
                        else
                        {
                            query = query.OrderBy(q => q.ID);
                        }
                    }
                    else if (filtroPesquisa.sSortDir_0 == "desc")
                    {
                        if (filtroPesquisa.iSortCol_0 == 1)
                        {
                            query = query.OrderByDescending(q => q.ID);
                        }
                        else if (filtroPesquisa.iSortCol_0 == 2)
                        {
                            query = query.OrderByDescending(q => q.Calc_Type);
                        }
                        else if (filtroPesquisa.iSortCol_0 == 3)
                        {
                            query = query.OrderByDescending(q => q.DT_reg);
                        }
                        else
                        {
                            query = query.OrderByDescending(q => q.Total);
                        }
                    }
                    else
                    {
                        query = query.OrderBy(q => q.ID);
                    }

                    query = query.Take(100);

                    ////Extract only current page
                    //msg.Instances = query.Skip(filtroPesquisa.iDisplayStart).Take(filtroPesquisa.iDisplayLength).ToList();


                    ////Campo improvisado para gerar o total de paginacao

                    msg.Code = query.Count();//Total de registro com filtros aplicados
                    //Total de registro no banco sem filtro aplicado Deve ser feito uma pesquisa direto na Tabela outra Query Deverrá ser informado em outro campo no grid CONtroller eu coloquei fixo 110 pra teste
                }
            }
            catch (Exception ex)
            {
                msg.Exception = ex;
            }
            return(msg);
        }
Exemplo n.º 9
0
        public ActionResult Create([Bind(Include = "cmbSHIFT_TYPE, cmbReport_Type, txtCopied, ID_Last_Calc, TotalCalc, ID_Last_Transaction, TotalLastCashier, ID_Last_TransactionVagner, TotalLastCashierVagner, ID_Last_TransactionCard, TotalLastCashierCard")] Dominio.Mensagens.TelaTransactions transaction)
        {
            if (string.IsNullOrEmpty(transaction.txtCopied))
            {
                ShowDialogMessage(TabDialogMessage.Danger, "Please, fill out the field: 'Past the Sheet here'");
            }
            if (transaction.cmbReport_Type == 0)
            {
                ShowDialogMessage(TabDialogMessage.Danger, "Please, select the Report Type");
            }

            if (ModelState.IsValid)
            {
                string txtCopied = Convert.ToString(Request["txtCopied"]);

                int                cmbReport_Type    = Convert.ToInt32(Request["cmbReport_Type"]);
                decimal            totalTransactions = 0;
                var                listStocks        = new List <Camada.Dominio.Entidades.Stock>();
                List <Transaction> listTrans         = new List <Transaction>();

                var lsTabTransaction = UtilsLibrary.GetListEnum(typeof(TabTransaction_Type));
                var lsTabPayment     = UtilsLibrary.GetListEnum(typeof(TabPayment_Type));
                var lsTabCard        = UtilsLibrary.GetListEnum(typeof(TabCard_Type));
                var lsTabProduct     = UtilsLibrary.GetListEnum(typeof(TabProduct_Type));

                if (cmbReport_Type > 0)
                {
                    foreach (string row in txtCopied.Split(new String[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries))
                    {
                        int         i     = 0;
                        Transaction trans = new Transaction();
                        if (!string.IsNullOrEmpty(row))
                        {
                            foreach (string cell in row.Split('\t'))
                            {
                                if (i == 0)
                                {
                                    trans.DT_Reg = Convert.ToDateTime(cell);
                                }
                                else if (i == 1)
                                {
                                    trans.DT_Reg = trans.DT_Reg.AddHours(Convert.ToDateTime(cell).Hour).AddMinutes(Convert.ToDateTime(cell).Minute).AddSeconds(Convert.ToDateTime(cell).Second);
                                }
                                else if (i == 2)
                                {
                                    trans.LogLogin = cell;
                                }
                                else if (i == 3)
                                {
                                    trans.Reservation_Number = cell;
                                }
                                else if (i == 4)
                                {
                                    trans.GuestName = cell;
                                }
                                else if (i == 5)
                                {
                                    if (!string.IsNullOrEmpty(cell))
                                    {
                                        trans.ID_Transaction_Type = Convert.ToInt32(lsTabTransaction.Where(w => w.StringDescription.Trim().ToUpper() == cell.Trim().ToUpper()).Select(s => s.StringValue).FirstOrDefault());
                                    }
                                }
                                else if (i == 6)
                                {
                                    if (!string.IsNullOrEmpty(cell))
                                    {
                                        trans.ID_Payment_Type = Convert.ToInt32(lsTabPayment.Where(w => w.StringDescription.Trim().ToUpper() == cell.Trim().ToUpper()).Select(s => s.StringValue).FirstOrDefault());
                                        //if (trans.ID_Payment_Type != (int)TabPayment_Type.Card)
                                        //    i++;
                                    }
                                }
                                else if (i == 7)
                                {
                                    if (!string.IsNullOrEmpty(cell) && trans.ID_Payment_Type == (int)TabPayment_Type.Card)
                                    {
                                        trans.ID_Card_Type = Convert.ToInt32(lsTabCard.Where(w => w.StringDescription.Trim().ToUpper() == cell.Trim().ToUpper()).Select(s => s.StringValue).FirstOrDefault());
                                    }
                                }
                                else if (i == 8)
                                {
                                    string stock = string.Empty;
                                    if (!string.IsNullOrEmpty(cell) && (transaction.cmbReport_Type == (int)TabReport_Type.Cash || transaction.cmbReport_Type == (int)TabReport_Type.Card))
                                    {
                                        stock = lsTabProduct.Where(w => w.StringDescription.Trim().ToUpper().Contains(cell.Trim().ToUpper())).Select(s => s.StringDescription).FirstOrDefault();
                                        if (!string.IsNullOrEmpty(stock))
                                        {
                                            var msgstock = new Camada.Dominio.Entidades.Stock();
                                            msgstock.AMOUNT          = 1;
                                            msgstock.DT_Entrada      = DateTime.UtcNow;
                                            msgstock.ID_ACTION_TYPE  = (int)TabAction_Type.Sold;
                                            msgstock.ID_PRODUCT_TYPE = Convert.ToInt32(stock);
                                            msgstock.LOGLOGIN        = User.Identity.Name;
                                            listStocks.Add(msgstock);
                                        }
                                    }
                                    trans.Description = !string.IsNullOrEmpty(stock) ? stock : cell;
                                }
                                else if (i == 9)
                                {
                                    string[] totalT = cell.Split('€');
                                    if (totalT[0].Contains("-"))
                                    {
                                        trans.Total = Convert.ToDecimal("-" + totalT[1].Trim());
                                    }
                                    else if (totalT[0].Contains("("))
                                    {
                                        trans.Total = Convert.ToDecimal("-" + totalT[1].Trim().Split(')')[0]);
                                    }
                                    else
                                    {
                                        trans.Total = Convert.ToDecimal(totalT[1].Trim());
                                    }

                                    totalTransactions += trans.Total;
                                }
                                i++;
                            }
                            listTrans.Add(trans);
                        }
                    }

                    decimal totalLastCashier = 0, totalFinal = 0, totalLastCalc = 0;
                    int     idLastCalc = 0;

                    var msgTotalLastCalc = Fachada.Repositorio.CALC.GetTotalLastCalc();
                    if (msgTotalLastCalc != null)
                    {
                        totalLastCalc = msgTotalLastCalc.Instance.Total;
                        idLastCalc    = msgTotalLastCalc.Instance.ID;
                    }

                    var totalTransaction = new Total_Transactions();
                    totalTransaction.ID_Report_Type = cmbReport_Type;

                    if (cmbReport_Type == (int)TabReport_Type.Cash)
                    {
                        var msgTotalLastCashier = Fachada.Repositorio.TOTAL_TRANSACTIONS.GetLastTotal_Transaction();
                        if (msgTotalLastCashier != null && msgTotalLastCashier.Instance != null && msgTotalLastCashier.Instance.TotalFinal.HasValue)
                        {
                            totalTransaction.ID_Last_Transaction = msgTotalLastCashier.Instance.ID;
                            totalLastCashier = msgTotalLastCashier.Instance.TotalFinal.Value;
                        }

                        totalFinal = totalTransactions + totalLastCashier;
                        totalTransaction.Last_Cashier_Total = totalLastCashier;
                    }
                    else if (cmbReport_Type == (int)TabReport_Type.Vagner)
                    {
                        var msgTotalLastCashierVagner = Fachada.Repositorio.TOTAL_TRANSACTIONS.GetLastTotal_Vagner();
                        if (msgTotalLastCashierVagner != null && msgTotalLastCashierVagner.Instance != null && msgTotalLastCashierVagner.Instance.TotalFinal.HasValue)
                        {
                            totalTransaction.ID_Last_Transaction = msgTotalLastCashierVagner.Instance.ID;
                            totalLastCashier = msgTotalLastCashierVagner.Instance.TotalFinal.Value;
                        }

                        totalFinal = totalTransactions + totalLastCashier;
                        totalTransaction.Last_Cashier_Total = totalLastCashier;
                    }
                    else if (cmbReport_Type == (int)TabReport_Type.Card)
                    {
                        var msgTotalLastCashierCard = Fachada.Repositorio.TOTAL_TRANSACTIONS.GetLastTotal_Card();
                        if (msgTotalLastCashierCard != null && msgTotalLastCashierCard.Instance != null && msgTotalLastCashierCard.Instance.TotalFinal.HasValue)
                        {
                            totalTransaction.ID_Last_Transaction = msgTotalLastCashierCard.Instance.ID;
                            totalLastCashier = msgTotalLastCashierCard.Instance.TotalFinal.Value;
                        }

                        totalFinal = totalTransactions + totalLastCashier;
                        totalTransaction.Last_Cashier_Total = totalLastCashier;

                        DateTime dtDayMonthYearReference = DateTime.UtcNow;
                        if (dtDayMonthYearReference.Hour >= 0 && dtDayMonthYearReference.Hour <= 5)
                        {
                            dtDayMonthYearReference = dtDayMonthYearReference.AddDays(-1);
                        }

                        totalTransaction.DayMonthYearReference = dtDayMonthYearReference.Date;
                    }

                    if (cmbReport_Type != (int)TabReport_Type.Card)
                    {
                        totalTransaction.ID_Calc               = idLastCalc;
                        totalTransaction.DifferenceFinalCalc   = totalLastCalc - totalFinal;
                        totalTransaction.DayMonthYearReference = DateTime.UtcNow.Date;
                    }

                    totalTransaction.ID_SHIFT_TYPE = transaction.cmbSHIFT_TYPE;

                    totalTransaction.TotalTransactions = totalTransactions;
                    totalTransaction.TotalFinal        = totalFinal;
                    totalTransaction.LogLogin          = (User != null && User.Identity != null && !string.IsNullOrEmpty(User.Identity.Name)) ? User.Identity.Name : string.Empty;
                    totalTransaction.DT_Reg            = DateTime.UtcNow;



                    var msgSaveTotal_Transactions = Fachada.Negocio.ManterTOTAL_TRANSACTIONS.Salvar(totalTransaction);
                    if (msgSaveTotal_Transactions.Result != Message.ResultType.Success)
                    {
                        return(Content(msgSaveTotal_Transactions.Description));
                    }

                    foreach (var item in listStocks)
                    {
                        item.ID_TOTAL_TRANSACTION = totalTransaction.ID;
                        var msgSaveStock = Fachada.Negocio.ManterSTOCK.Save(item);
                        if (msgSaveStock.Result != Message.ResultType.Success)
                        {
                            return(Content(msgSaveStock.Description));
                        }
                    }

                    foreach (var item in listTrans)
                    {
                        item.ID_Total_Transactions = totalTransaction.ID;
                    }

                    var msgSaveTransactions = Fachada.Negocio.ManterTRANSACTIONS.SaveList(listTrans.ToArray());
                    if (msgSaveTransactions.Result != Message.ResultType.Success)
                    {
                        return(Content(msgSaveTransactions.Description));
                    }

                    return(RedirectToAction("Details", "TotalTransactions", new { id = totalTransaction.ID }));
                }
            }

            carregaCombos();
            return(View(transaction));
        }