private void bunifuThinButton23_Click(object sender, EventArgs e) { if (UserCurrent.getCurrentUser().FlagAdmin == true) { if (position >= 0) { _storeController.deleteForId(_storeController.List()[position].Id); fillData(); } else { MessageBox.Show("Selecione o armazem"); } } else { if (UserCurrent.getPermission().Stock) { if (position >= 0) { _storeController.deleteForId(_storeController.List()[position].Id); fillData(); } else { MessageBox.Show("Selecione o armazem"); } } } position = -1; }
public async Task <UserCurrent> GetCurrentUser() { var idStr = userAccessor.GetCurrentUserId(); var id = Convert.ToInt32(idStr); var result = await db.NhanVien.SingleOrDefaultAsync(acc => acc.MaNv == id); if (result == null) { throw new Exception("Không tồn tại nhân viên"); } if (!result.KichHoat) { throw new Exception("Tài Khoản Bị Vô Hiệu Hóa"); } if (result.MaChucVu == null) { throw new Exception("Nhân Viên Chưa Có Chức Vụ"); } var token = jwtgenerator.CreateToken(result); var userCurrent = new UserCurrent { MaNv = result.MaNv, TenNv = result.TenNv, MaChucVu = (int)result.MaChucVu, Token = token, Hinh = result.Hinh }; return(userCurrent); }
public async Task <UserCurrent> Login(TaiKhoan tk) { var acc = await db.NhanVien .FirstOrDefaultAsync(nv => nv.TenDangNhap == tk.TenDangNhap && nv.MatKhau == tk.MatKhau); if (acc == null) { throw new Exception("Sai Tài Khoản Hoặc Mật Khẩu"); } if (acc.KichHoat == false) { throw new Exception("Tài Khoản Đã Bị Vô Hiệu Hóa"); } if (acc.MaChucVu == null) { throw new Exception("Tài Khoản Chưa Được Phân Quyền"); } var user = new UserCurrent { MaNv = acc.MaNv, TenNv = acc.TenNv, Token = jwtgenerator.CreateToken(acc), MaChucVu = (int)acc.MaChucVu, }; return(user); }
private void bunifuThinButton24_Click(object sender, EventArgs e) { if (txtUser.Text.Trim() != "" && !hint) { if (txtPassword.Text.Trim() != "" && !hint2) { System.Configuration.Configuration c = System.Configuration.ConfigurationManager.OpenExeConfiguration(System.Configuration.ConfigurationUserLevel.None); User us; try { if (UserCurrent.getCurrentUser() != null) { usController = new UserController(); } us = usController.Logar(txtUser.Text, txtPassword.Text); if (us != null) { SystemInfoCurrent.initialize(); UserCurrent.initialize(us); if (us.FlagFirstLogin) { new FrmUserFirstLogin(us, this).Show(); } else { new Main(this).Show(); } txtUser.Focus(); txtUser.Select(0, 0); Hide(); txtPassword.Clear(); txtUser.Clear(); } else { MessageBox.Show("usuario ou senha incorrestos,\n TRY AGAIN"); txtPassword.Clear(); txtUser.Clear(); txtUser.Focus(); } } catch (Exception error) { MessageBox.Show(error.Message); us = null; } } else { MessageBox.Show("Insira a senha"); txtPassword.Focus(); } } else { MessageBox.Show("Insira o usuario"); } }
public FrmPosRestaurant(Main main) { InitializeComponent(); lblUser.Text = UserCurrent.getCurrentUser().Nome; this.main = main; idUser = UserCurrent.getCurrentUser().Id; if (UserCurrent.getCurrentUser().FlagAdmin) { isAdminActive = true; } toGridControlProducts(); getSerie(); string hora = DateTime.Now.Hour.ToString(); string min = DateTime.Now.Minute.ToString(); if (int.Parse(min) < 10) { min = "0" + min; } if (int.Parse(hora) < 10) { hora = "0" + hora; } lblHora.Text = hora + ":" + min; }
private void btnEdit_Click(object sender, EventArgs e) { if (position >= 0) { if (UserCurrent.getCurrentUser().FlagAdmin == true) { idProd = MethodsTable.getCellValueRowSelectedIdInt(gridViewProducts); new FrmProducts(this, idProd).ShowDialog(); } else { if (UserCurrent.getPermission().Stock) { idProd = MethodsTable.getCellValueRowSelectedIdInt(gridViewProducts); if (position >= 0) { idProd = MethodsTable.getCellValueRowSelectedIdInt(gridViewProducts); new FrmProducts(this, idProd).ShowDialog(); } else { MessageBox.Show("Selecione o produto"); } } } } position = -1; /// }
private void bunifuThinButton21_Click(object sender, EventArgs e) { // string hora = DateTime.Now.Hour <= 9 ? "0" + DateTime.Now.Hour. : DateTime.Now.Hour; Turno t = new Turno() { Data = DateTime.Now, Estado = "Aberto", Hora = DateTime.Now.ToShortTimeString(), Caixa = decimal.Parse(textEdit1.Text), Abertura = decimal.Parse(textEdit1.Text), Tpa = 0, UserId = UserCurrent.getCurrentUser().Id, UserName = UserCurrent.getCurrentUser().Nome, DataF = DateTime.Now, HoraF = DateTime.Now.ToShortTimeString(), }; TurnoController _turnoController = new TurnoController(); _turnoController.insert(t); TurnoCurrent.initialize(t); frmC.setButtonFalse(); frmC.fillData(); FrmReportView frm = new FrmReportView(); frm.PrintOpenBox(TurnoCurrent.getTurnoCurrent()); Close(); // Hide(); }
public async Task <bool> AddOrder_Input(OrderModel model, UserCurrent User, bool isDone = true, int OrderSuppliersId = 0) { model.Id_To = User.BranchesId; model.TypeOrder = (int)TypeOrder.Input; model.DateCreate = DateTime.Now; model.EmployeeCreate = User.UserId; if (OrderSuppliersId > 0) { model.Id_From = OrderSuppliersId; } model.Status = isDone ? (int)StatusOrder_Input.Done : (int)StatusOrder_Input.Process; var objOrder = Mapper.Map <soft_Order>(model); unitOfWork.OrderInputRepository.Add(objOrder); if (OrderSuppliersId > 0 && isDone) { UpdateOrderSuppliers(model, OrderSuppliersId); } if (isDone) { UpdateStockByBranches(model, User); } else { UpdatePriceCompare(model); } await unitOfWork.SaveChanges(); return(true); }
private void Main_FormClosed(object sender, FormClosedEventArgs e) { if (appExit) { Application.Exit(); UserCurrent.logOf(); } }
private void simpleButton2_Click(object sender, EventArgs e) { if (UserCurrent.getCurrentUser().FlagAdmin) { main.Show(); Close(); } else { Close(); } }
public void initDate(Turno t) { lblValor.Text = t.Caixa.ToString();; lblUser.Text = UserCurrent.getCurrentUser().Nome; lblDataHora.Text = t.Data.ToString(); string rootPath = Application.StartupPath; Company company = SystemInfoCurrent.getCurrentCompany(); xrlblCompany.Text = company.Empresa; xrlblNif.Text = "NIF: " + company.Nif; xrlblTel.Text = "Telefone: " + company.Tel; }
public PDV() { InitializeComponent(); idUser = UserCurrent.getCurrentUser().Id; getSerie(); _codigoFaturaAtual = 1; if (!Directory.Exists(pathImgs)) { Directory.CreateDirectory(pathImgs); } allowPermissionFolder(pathImgs); CalcCodigoFaturaAtual(); }
private void btnLogOf_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { appExit = false; if (MessageBox.Show("Deseja terminar Sessão..?", "Terminar Sessão", MessageBoxButtons.YesNo) == DialogResult.Yes) { UserCurrent.logOf(); _frmLogin.Show(); Close(); } else { appExit = true; } }
private void barButtonItem42_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { if (UserCurrent.getCurrentUser().FlagAdmin == true) { if (new SerieController().ListALL().Count > 0) { if (TurnoCurrent.getTurnoCurrent() == null) { MessageBox.Show("Abra o Caixa Primeiro"); } else { FrmPosRestaurant frmPos = new FrmPosRestaurant(this); frmPos.Show(); Hide(); } } else { MessageBox.Show("Cadastre uma serie no sistema"); } } else { if (UserCurrent.getPermission().Venda) { if (new SerieController().ListALL().Count > 0) { if (new TableController().ListALL().Count > 0) { FrmPosRestaurant frmPos = new FrmPosRestaurant(this); frmPos.Show(); Hide(); } else { MessageBox.Show("Cadastre pelo menos uma(1) mesa"); } } else { MessageBox.Show("Cadastre uma serie no sistema"); } } else { MessageBox.Show("Não tem permissão para completar essa operação"); } } }
public async Task <bool> AddOrder_Branches(OrderModel model, UserCurrent User) { model.TypeOrder = (int)TypeOrder.OrderBranches; model.DateCreate = DateTime.Now; model.EmployeeCreate = User.UserId; var objOrder = Mapper.Map <soft_Order>(model); unitOfWork.OrderBranchesRepository.Add(objOrder); await unitOfWork.SaveChanges(); return(true); }
private void btnNewCategory_Click(object sender, EventArgs e) { if (UserCurrent.getCurrentUser().FlagAdmin == true) { new FrmCategorySave(this).ShowDialog(); } else { if (UserCurrent.getPermission().Stock) { new FrmCategorySave(this).ShowDialog(); } else { MessageBox.Show("Não tem permissão para completar essa operação"); } } }
private void barButtonItem8_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { if (UserCurrent.getCurrentUser().FlagAdmin == true) { new FrmOutProduct().ShowDialog(); } else { if (UserCurrent.getPermission().Stock) { new FrmOutProduct().ShowDialog(); } else { MessageBox.Show("Não tem permissão para completar essa operação"); } } }
private void bunifuThinButton21_Click(object sender, EventArgs e) { if (UserCurrent.getCurrentUser().FlagAdmin == true) { FrmStoreSave frm = new FrmStoreSave(this); frm.ShowDialog(); } else { if (UserCurrent.getPermission().Stock) { FrmStoreSave frm = new FrmStoreSave(this); frm.ShowDialog(); } else { MessageBox.Show("Não tem permissão para completar essa operação"); } } }
private void btnPOS_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { if (UserCurrent.getCurrentUser().FlagAdmin == true) { if (new SerieController().ListALL().Count > 0) { FrmPosPdv frmPost = new FrmPosPdv(this); frmPost.Show(); Hide(); } else { MessageBox.Show("Cadastre uma serie no sistema"); } } else { if (UserCurrent.getPermission().Stock) { if (new SerieController().ListALL().Count > 0) { FrmPosPdv frmPost = new FrmPosPdv(this); frmPost.Show(); Hide(); } else { MessageBox.Show("Cadastre uma serie no sistema"); } } else { MessageBox.Show("Não tem permissão para completar essa operação"); } } }
public void openInvoiceForm(string type, FrmInvoice frm) { if (UserCurrent.getCurrentUser().FlagAdmin == true) { if (isFormInactive(frm)) { activeForm(frm = new FrmInvoice(type)); } } else { if (UserCurrent.getPermission().Venda) { if (isFormInactive(frm)) { activeForm(frm = new FrmInvoice(type)); } } else { MessageBox.Show("Não tem permissão para completar essa operação"); } } }
private void btnNDC_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { if (UserCurrent.getCurrentUser().FlagAdmin == true) { if (isFormInactive(frmInvoiceCredite)) { activeForm(frmInvoiceCredite = new FrmInvoicesForCreditNote()); } } else { if (UserCurrent.getPermission().Stock) { if (isFormInactive(frmInvoiceCredite)) { activeForm(frmInvoiceCredite = new FrmInvoicesForCreditNote()); } } else { MessageBox.Show("Não tem permissão para completar essa operação"); } } }
public FrmPosPdv(Main main) { InitializeComponent(); this.main = main; new FrmPosPrinter().ShowDialog(); if (UserCurrent.getCurrentUser().FlagAdmin) { isAdminActive = true; } toGridControlProducts(); gridCategory.DataSource = _categoryController.ListALLAsNoTracking(); getSerie(); string hora = DateTime.Now.Hour.ToString(); string min = DateTime.Now.Minute.ToString(); if (int.Parse(min) < 10) { min = "0" + min; } if (int.Parse(hora) < 10) { hora = "0" + hora; } lblHora.Text = hora + ":" + min; /* PictureEdit pic = new PictureEdit(); * pic.Image = Image.FromFile(@"C:\Users\FernandoWonder\Pictures\detalhe_empresa.png"); * repositoryItemPictureEdit1.HtmlImages = pic.Image; * //pic.EditValue = Image.FromFile(""); * RepositoryItemPictureEdit edit = new RepositoryItemPictureEdit(); * edit.HtmlImages = pic; * * edit.HtmlImages = Image.FromFile(@"C:\Users\FernandoWonder\Pictures\detalhe_empresa.png"); */ //cardView1.Columns["Id"].Visible = false; }
private void UpdateStockByBranches(OrderModel order, UserCurrent User, bool is_create = false) { foreach (var item in order.Detail) { var StockProduct = unitOfWork.BrachesStockRepository.FindBy(o => o.ProductId == item.ProductId).ToList(); if (order.TypeOrder == (int)TypeOrder.Input) { var product = unitOfWork.ProductRepository.FindBy(o => o.id == item.ProductId).FirstOrDefault(); var priceBase = product.PriceBase; if (product != null) { #region Product product.PriceInput = (int)item.Price; product.PriceCompare = item.PriceCompare; #region Giá cơ bản product.PriceBase_Old = product.PriceBase; var stockbySum = StockProduct != null && StockProduct.Count > 0 ? StockProduct.Sum(o => o.Stock_Total) : 0; var pricebase_old = product.PriceBase != null ? product.PriceBase : 0; var sumTotal = (item.Total + stockbySum); product.PriceBase = (int)(((stockbySum * pricebase_old) + (item.Total * (int)item.Price)) / (sumTotal != 0 ? sumTotal : 1)); unitOfWork.ProductRepository.Update(product, o => o.PriceBase, o => o.PriceInput, o => o.PriceBase_Old, o => o.PriceCompare); #endregion #region Giá sỉ if (priceBase != product.PriceBase) { UpdatePriceWholesale(product, User); } #endregion #endregion #region Stock var stockTo = StockProduct.FirstOrDefault(o => o.ProductId == item.ProductId && o.BranchesId == order.Id_To); if (stockTo != null) { stockTo.Stock_Total = stockTo.Stock_Total + item.Total; stockTo.DateUpdate = DateTime.Now; stockTo.EmployeeUpdate = User.UserId; unitOfWork.BrachesStockRepository.Update(stockTo, o => o.Stock_Total, o => o.EmployeeUpdate, o => o.DateUpdate); } else { var stockNewTo = new soft_Branches_Product_Stock { BranchesId = order.Id_To, ProductId = item.ProductId, Stock_Total = item.Total, DateCreate = DateTime.Now, EmployeeCreate = order.EmployeeCreate }; unitOfWork.BrachesStockRepository.Add(stockNewTo); } #endregion } } if (order.TypeOrder == (int)TypeOrder.Output) { #region stockTo var stockTo = StockProduct.FirstOrDefault(o => o.ProductId == item.ProductId && o.BranchesId == order.Id_To); if (stockTo != null) { stockTo.Stock_Total = stockTo.Stock_Total + item.Total; stockTo.DateUpdate = DateTime.Now; stockTo.EmployeeUpdate = User.UserId; unitOfWork.BrachesStockRepository.Update(stockTo, o => o.Stock_Total, o => o.EmployeeUpdate, o => o.DateUpdate); } else { stockTo = new soft_Branches_Product_Stock { ProductId = item.ProductId, BranchesId = User.BranchesId, DateCreate = DateTime.Now, Stock_Total = item.Total, EmployeeCreate = User.UserId }; unitOfWork.BrachesStockRepository.Add(stockTo); } #endregion #region stockFrom var stockFrom = StockProduct.FirstOrDefault(o => o.ProductId == item.ProductId && o.BranchesId == order.Id_From); if (stockFrom != null) { stockTo.Stock_Total = stockFrom.Stock_Total - item.Total; stockTo.DateUpdate = order.DateCreate; stockTo.EmployeeUpdate = order.EmployeeCreate; unitOfWork.BrachesStockRepository.Update(stockTo, o => o.Stock_Total, o => o.EmployeeUpdate, o => o.DateUpdate); } else { var stockNewTo = new soft_Branches_Product_Stock { BranchesId = order.Id_From, ProductId = item.ProductId, Stock_Total = 0 - item.Total, DateCreate = order.DateCreate, EmployeeCreate = order.EmployeeCreate, DateUpdate = null, EmployeeUpdate = null }; unitOfWork.BrachesStockRepository.Add(stockNewTo); } #endregion } if (order.TypeOrder == (int)TypeOrder.Sale) { #region Stock var stockBraches = StockProduct.FirstOrDefault(o => o.ProductId == item.ProductId && o.BranchesId == User.BranchesId); if (stockBraches != null) { double total_stock = 0; bool isUpdate = false; if (is_create) { total_stock = stockBraches.Stock_Total - item.Total; isUpdate = true; } else { switch (order.Status) { case (int)StatusOrder_Sale.Cancel: total_stock = stockBraches.Stock_Total + item.Total; isUpdate = true; break; //case (int)StatusOrder_Sale.Done: // total_stock = stockBraches.Stock_Total - item.Total; // isUpdate = true; // break; } } if (isUpdate) { stockBraches.Stock_Total = total_stock; unitOfWork.BrachesStockRepository.Update(stockBraches, o => o.Stock_Total); } } else { double total_stock = 0; bool isUpdate = false; if (!is_create) { switch (order.Status) { case (int)StatusOrder_Sale.Cancel: total_stock = 0; isUpdate = true; break; case (int)StatusOrder_Sale.Done: total_stock = 0 - item.Total; isUpdate = true; break; } } else { total_stock = 0 - item.Total; isUpdate = true; } if (isUpdate) { var newstock = new soft_Branches_Product_Stock { BranchesId = User.BranchesId, ProductId = item.ProductId, Stock_Total = total_stock, DateCreate = DateTime.Now, EmployeeCreate = User.UserId }; unitOfWork.BrachesStockRepository.Add(newstock); } } #endregion } } }
public void UpdatePriceWholesale(shop_sanpham product, UserCurrent User, bool isCommit = false) { #region Giá sỉ var channelOnline = unitOfWork.ChannelRepository.FindBy(o => o.Type == (int)TypeChannel.IsChannelOnline && o.Id == User.ChannelId).FirstOrDefault(); bool isChange = false; if (channelOnline != null) { var priceOL = product.soft_Channel_Product_Price.FirstOrDefault(o => o.soft_Channel.Type == (int)TypeChannel.IsChannelOnline); int?priceWholesale = 0; if (priceOL != null) { var total = (int)((priceOL.Price - product.PriceBase) / 5.3) + product.PriceBase; double round = Convert.ToDouble(total.Value); priceWholesale = Convert.ToInt32(Helpers.Round_Double(round, -3)); } else { var total = (int)((0 - product.PriceBase) / 5.3) + product.PriceBase; double round = Convert.ToDouble(total.Value); priceWholesale = Convert.ToInt32(Helpers.Round_Double(round, -3)); } var priceSi = unitOfWork.ChanelPriceRepository.Get(o => o.ProductId == product.id && o.soft_Channel.Type == (int)TypeChannel.IsChannelWholesale).FirstOrDefault(); if (priceSi != null) { priceSi.Price = (int)priceWholesale; unitOfWork.ChanelPriceRepository.Update(priceSi, o => o.Price); isChange = true; } else { var ChannelSi = unitOfWork.ChannelRepository.Get(o => o.Type == (int)TypeChannel.IsChannelWholesale).FirstOrDefault(); unitOfWork.ChanelPriceRepository.Add(new soft_Channel_Product_Price { Price = (int)priceWholesale, ChannelId = ChannelSi.Id, DateCreate = DateTime.Now, EmployeeCreate = User.UserId, ProductId = product.id }); isChange = true; } } if (isCommit && isChange) { unitOfWork.SaveChanges(); } #endregion }
/* public bool verificaData() * { * Invoice ivlast = _invoiceController.ListALLAsNoTracking().LastOrDefault(); * if(ivlast != null) * { * if(ivlast.DataCadastro > DateTime.Now) * { * MessageBox.Show("Verifique se a data do Sistema está correta..!"); * return false; * } * } * return true; * }*/ public void salvar() { //Series serie = _serieController.ListALLAsNoTracking()[cmbSerie.SelectedIndex]; try { CalcCodigoFaturaAtual(); obs = txtDescricao.Text; string invoiceNo = getInvoiceTypeTipo() + " " + _serieController.ListALLAsNoTracking()[cmbSerie.SelectedIndex].Serie + "/" + _codigoFaturaAtual; DateTime dataAtual = DateTime.Now; //string GrossTotal = (TotalIva + totalIncidencia).ToString("F").Replace(',', '.'); string GrossTotal = (totGeral).ToString("F3").Replace(',', '.'); // string dadosHash2 = dataAtual.ToString("yyyy-MM-dd") + ";" + dataAtual.ToString("yyyy-MM-ddTHH:mm") + ";" + invoiceNo + ";" + (TotalIva + totalIncidencia).ToString("N2").Replace(",", ".") + ";"; string dadosHash = dataAtual.ToString("yyyy-MM-dd") + ";" + dataAtual.ToString("yyyy-MM-ddTHH:mm:ss") + ";" + invoiceNo + ";" + GrossTotal + ";"; dadosHash += lastInvoice != null ? lastInvoice.Hash : ""; //dadosHash = lastInvoice != null ? dadosHash + lastInvoice.Hash : dadosHash; string Hash = Methods.gerarHash(dadosHash, invoiceNo); Invoice invoice = new Invoice() { InvoiceDate = dataAtual.ToString("yyyy-MM-dd"), Codigo = _codigoFaturaAtual, ClienteId = ClienteID, SeriesId = idSerie, InvoiceNo = invoiceNo, TipoDocumentoId = idTipoDocumento, Desconto = totDescontoProducts, Observacao = obs, TotalImposto = TotalIva, TotalIncidencia = totalIncidencia, TotalLiquidar = cmbInvoiceType.Text == "FT" ? totalIncidencia + TotalIva : 0, UserId = UserCurrent.getCurrentUser().Id, Troco = troco, ValorPago = valorPago, FormaPagamentoId = cmbInvoiceType.Text == "FT" ? "CD" : cmbInvoiceType.Text == "PP" || cmbInvoiceType.Text == "FP" ? null : _paymentWays.ListALLAsNoTracking()[cmbPaymentMechanism.SelectedIndex].Id, DataCadastro = dataAtual, Hash = Hash, DataVencimento = dtVencimento.Enabled ? dtVencimento.Value : DateTime.Now, }; _invoiceController.insert(invoice); invoice = _invoiceController.getForInvoiceNo(invoiceNo); int idFatura = invoice != null ? invoice.Id : 0; if (idFatura == 0) { MessageBox.Show("Fatura Nula"); } _invoiceController.Dispose(); _invoiceController = new InvoiceController(); /*string dadosHash = invoice.InvoiceDate + ";" + invoice.DataCadastro.ToString("yyyy-MM-ddTHH:mm:ss") + ";" + invoice.InvoiceNo + ";" + invoice.TotalGeral.ToString("N2").Replace(",", ".") + ";"; * string dadosHash2 = invoice.InvoiceDate + ";" + invoice.DataCadastro.ToString("yyyy-MM-ddTHH:mm") + ";" + invoice.InvoiceNo + ";" + invoice.TotalGeral.ToString("N2").Replace(",", ".") + ";"; * dadosHash = lastInvoice != null ? dadosHash2 + lastInvoice.Hash : dadosHash; * invoice.Hash = Methods.gerarHash(dadosHash);*/ CurrentAccountSystem currentAccountSystem = _currentAcountSystemController.ListALL()[cmbConta.SelectedIndex]; currentAccountSystem.Saldo += invoice.TotalGeral; _currentAcountSystemController.update(currentAccountSystem); foreach (var item in __listaSelected) { Stock stock = _stock.getStockArmazemProduct(item.ProdutoId, item.Stock.ArmazemId); stock.Quantidade -= item.Quantidade; _stock.update(stock); string movitoISE = null; Product product = _products.getOne(item.ProdutoId); if (product.MotivoISEId != null) { movitoISE = product.MotivoISE.MencaoFatura; } ProductSales productSale = new ProductSales() { Preco = item.Preco, FaturaId = idFatura, ProductId = item.ProdutoId, Desconto = item.Desconto, Descricao_Produto = product.Descricao, Quantidade = item.Quantidade, StockId = item.StockId, Taxa = product.CodigoTaxa.Taxa, Unidade = product.UnidadeBase.Simbolo, MotivoISEId = product.MotivoISEId, MotivoIsencao = movitoISE, }; _sales.insert(productSale); } __listaSelected.Clear(); gdvControlProducts.DataSource = __listaSelected; gdvControlProducts.RefreshDataSource(); CalcCodigoFaturaAtual(); print(idFatura); } catch (Exception error) { MessageBox.Show(error.Message); } }
public void salvar() { CalcCodigoFaturaAtual(); DateTime dataAtual = DateTime.Now; string GrossTotal = (totGeral).ToString().Replace(',', '.'); // string dadosHash2 = dataAtual.ToString("yyyy-MM-dd") + ";" + dataAtual.ToString("yyyy-MM-ddTHH:mm") + ";" + invoiceNo + ";" + (TotalIva + totalIncidencia).ToString("N2").Replace(",", ".") + ";"; string dadosHash = dataAtual.ToString("yyyy-MM-dd") + ";" + dataAtual.ToString("yyyy-MM-ddTHH:mm:ss") + ";" + invoiceNo + ";" + GrossTotal + ";"; dadosHash += lastInvoice != null ? lastInvoice.Hash : ""; string Hash = Methods.gerarHash(dadosHash, invoiceNo); _invoiceNota = new Invoice() { ClienteId = _invoiceCorrigir.ClienteId, // Trocar depois, pois o motivo da nota pode erro no cliente Codigo = _codigoFaturaAtual, Desconto = totDescontoProducts, InvoiceDate = dataAtual.ToString("yyyy-MM-dd"), InvoiceNo = invoiceNo, TipoDocumentoId = idTipoDocumento, RazaoNota = cmbMotivoNota.Text, SeriesId = idSerie, TipoOperacaoId = (cmbTipoOperacaoNota.SelectedIndex + 1), TotalImposto = TotalIva, TotalIncidencia = totalIncidencia, UserId = UserCurrent.getCurrentUser().Id, Hash = Hash, Referencia = _invoiceCorrigir.InvoiceNo, FormaPagamentoId = _invoiceCorrigir.FormaPagamentoId, }; int r = _invoiceController.insert(_invoiceNota); _invoiceNota = _invoiceController.getForInvoiceNo(invoiceNo); int idFatura = _invoiceNota != null ? _invoiceNota.Id : 0; if (idFatura == 0) { MessageBox.Show("Fatura Nula"); } //_invoiceController.Dispose(); //_invoiceController = new InvoiceController(); foreach (var item in __productSales) { Stock stock = _stock.getStockArmazemProduct(item.ProductId, item.Stock.ArmazemId); stock.Quantidade += item.Quantidade; _stock.update(stock); ProductSales productSale = new ProductSales() { Desconto = item.Desconto, FaturaId = idFatura, MotivoIsencao = item.MotivoIsencao, Descricao_Produto = item.Product.Descricao, ProductId = item.ProductId, Quantidade = item.Quantidade, StockId = item.StockId, Taxa = item.Taxa, Unidade = item.Unidade, Preco = item.Preco, Observacao = item.Observacao, MotivoISEId = item.MotivoISEId, }; _sales.insert(productSale); } //__listaSelected.Clear(); // gdvControlProducts.DataSource = __listaSelected; gdvControlProducts.RefreshDataSource(); CalcCodigoFaturaAtual(); print(idFatura); }
private void barButtonItem7_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { if (UserCurrent.getCurrentUser().FlagAdmin == true) { StorageController _storageController = new StorageController(); ProviderController _providerController = new ProviderController(); if (_providerController.ListALLAsNoTracking().Count > 0) { if (_storageController.List().Count > 0) { if (isFormInactive(frmEntry)) { frmEntry = new FrmEntryProducts(); frmEntry.MdiParent = this; frmEntry.Show(); } } else { MessageBox.Show("Nenhum armazem encontrado \nInsira um armazem primeiro"); new FrmStoreSave().ShowDialog(); } } else { MessageBox.Show("Nenhum Fornecedor encontrado \nInsira um Fornecedor primeiro"); new FrmFornecedorSave(true).ShowDialog(); } } else { if (UserCurrent.getPermission().Stock) { StorageController _storageController = new StorageController(); ProviderController _providerController = new ProviderController(); if (_providerController.ListALLAsNoTracking().Count > 0) { if (_storageController.List().Count > 0) { if (isFormInactive(frmEntry)) { frmEntry = new FrmEntryProducts(); frmEntry.MdiParent = this; frmEntry.Show(); } } else { MessageBox.Show("Nenhum armazem encontrado \nInsira um armazem primeiro"); new FrmStoreSave().ShowDialog(); } } else { MessageBox.Show("Nenhum Fornecedor encontrado \nInsira um Fornecedor primeiro"); new FrmFornecedorSave(true).ShowDialog(); } } else { MessageBox.Show("Não tem permissão para completar essa operação"); } } }
private void btnSaveRecibo_Click(object sender, EventArgs e) { if (!Methods.verificaData()) { MessageBox.Show("Verifique se a data do Sistema está correta..!"); } else if (_faturasSelecionadas.Count > 0) { CalcCodigoFaturaAtual(); obs = txtDescricao.Text; string invoiceNo = getInvoiceTypeTipo() + " " + _serieController.ListALLAsNoTracking()[cmbSerie.SelectedIndex].Serie + "/" + _codigoFaturaAtual; DateTime dataAtual = DateTime.Now; //string GrossTotal = (TotalIva + totalIncidencia).ToString("F").Replace(',', '.'); string GrossTotal = (totGeral).ToString("F3").Replace(',', '.'); // string dadosHash2 = dataAtual.ToString("yyyy-MM-dd") + ";" + dataAtual.ToString("yyyy-MM-ddTHH:mm") + ";" + invoiceNo + ";" + (TotalIva + totalIncidencia).ToString("N2").Replace(",", ".") + ";"; string dadosHash = dataAtual.ToString("yyyy-MM-dd") + ";" + dataAtual.ToString("yyyy-MM-ddTHH:mm:ss") + ";" + invoiceNo + ";" + GrossTotal + ";"; dadosHash += lastInvoice != null ? lastInvoice.Hash : ""; //dadosHash = lastInvoice != null ? dadosHash + lastInvoice.Hash : dadosHash; string Hash = Methods.gerarHash(dadosHash, invoiceNo); Invoice documento = new Invoice() { InvoiceDate = dataAtual.ToString("yyyy-MM-dd"), Codigo = _codigoFaturaAtual, ClienteId = ClienteID, SeriesId = idSerie, InvoiceNo = invoiceNo, TipoDocumentoId = idTipoDocumento, Observacao = obs, UserId = UserCurrent.getCurrentUser().Id, FormaPagamentoId = _paymentWays.ListALLAsNoTracking()[cmbFormaPagamentoRecibo.SelectedIndex].Id, DataCadastro = dataAtual, Hash = Hash, }; _invoiceController.insert(documento); documento = _invoiceController.getForInvoiceNo(invoiceNo); int idFatura = documento != null ? documento.Id : 0; if (idFatura == 0) { MessageBox.Show("Fatura Nula"); } else { _invoiceController.Dispose(); _invoiceController = new InvoiceController(); } ReciboController _rcController = new ReciboController(); int reciboId = 0; // Vai receber o id do recibo apos ser cadastrado Recibo recibo = new Recibo() { DataUltimoEstadoPagamento = DateTime.Now, DocumentoId = documento.Id, UserUltimoEstadoDocumentoId = UserCurrent.getCurrentUser().Id, TotalRecibo = decimal.Parse(lblTotalRecibo.Text), }; _rcController.insert(recibo); recibo = _rcController.getForDocumentId(idFatura); reciboId = recibo != null ? recibo.Id : 0; if (reciboId == 0) { MessageBox.Show("Recibo Nulo"); } else { salvarPagamentos(reciboId); print(idFatura); clearRecibo(); } } else { MessageBox.Show("Nenhuma Fatura Selecionada"); } }
public List <shop_sanpham> SearchBy1(PagingInfo pageinfo, out int count, out int min, out Dictionary <string, object> values, UserCurrent User) { values = new Dictionary <string, object>(); var lstTmp = GetAll(); #region Fillter if (pageinfo.filterby != null && pageinfo.filterby.Count > 0) { foreach (var item in pageinfo.filterby) { var key = 0; if (item.Fiter.Equals("Price") || item.Fiter.Equals("Stock")) { key = int.Parse(item.Name); } else { key = int.Parse(item.Value); } switch (item.Fiter) { case "Catalog": lstTmp = lstTmp.Where(o => o.CatalogId > 0 && o.CatalogId.Equals(key)); break; case "Suppliers": lstTmp = lstTmp.Where(o => o.SuppliersId > 0 && o.SuppliersId.Equals(key)); break; case "Status": lstTmp = lstTmp.Where(o => o.Status > 0 && o.Status.Equals(key)); break; case "VAT": lstTmp = lstTmp.Where(o => o.StatusVAT > 0 && o.StatusVAT.Equals(key)); break; case "Price": case "Stock": lstTmp = lstTmp.Where(o => item.Ids.Contains(o.id)); break; } } } #endregion #region Sort bool isSort = false; if (!string.IsNullOrEmpty(pageinfo.sortby)) { isSort = true; switch (pageinfo.sortby) { case "DateCreate": if (pageinfo.sortbydesc) { lstTmp = lstTmp.OrderByDescending(o => o.DateCreate); } else { lstTmp = lstTmp.OrderBy(o => o.DateCreate); } break; case "Id": if (pageinfo.sortbydesc) { lstTmp = lstTmp.OrderByDescending(o => o.id); } else { lstTmp = lstTmp.OrderBy(o => o.id); } break; case "Barcode": if (pageinfo.sortbydesc) { lstTmp = lstTmp.OrderByDescending(o => o.Barcode); } else { lstTmp = lstTmp.OrderBy(o => o.Barcode); } break; case "PriceBase": if (pageinfo.sortbydesc) { lstTmp = lstTmp.OrderByDescending(o => o.PriceBase); } else { lstTmp = lstTmp.OrderBy(o => o.PriceBase); } break; case "PriceBase_Old": if (pageinfo.sortbydesc) { lstTmp = lstTmp.OrderByDescending(o => o.PriceBase_Old); } else { lstTmp = lstTmp.OrderBy(o => o.PriceBase_Old); } break; case "PriceCompare": if (pageinfo.sortbydesc) { lstTmp = lstTmp.OrderByDescending(o => o.PriceCompare); } else { lstTmp = lstTmp.OrderBy(o => o.PriceCompare); } break; case "PriceInput": if (pageinfo.sortbydesc) { lstTmp = lstTmp.OrderByDescending(o => o.PriceInput); } else { lstTmp = lstTmp.OrderBy(o => o.PriceInput); } break; case "ProductName": if (pageinfo.sortbydesc) { lstTmp = lstTmp.OrderByDescending(o => o.tensp); } else { lstTmp = lstTmp.OrderBy(o => o.tensp); } break; case "Code": if (pageinfo.sortbydesc) { lstTmp = lstTmp.OrderByDescending(o => o.CatalogId); } else { lstTmp = lstTmp.OrderBy(o => o.CatalogId); } break; case "StatusVAT": if (pageinfo.sortbydesc) { lstTmp = lstTmp.OrderByDescending(o => o.StatusVAT); } else { lstTmp = lstTmp.OrderBy(o => o.StatusVAT); } break; case "Stock_Sum": if (pageinfo.sortbydesc) { lstTmp = lstTmp.OrderByDescending(o => o.soft_Branches_Product_Stock.Sum(p => p.Stock_Total)); } else { lstTmp = lstTmp.OrderBy(o => o.soft_Branches_Product_Stock.Sum(p => p.Stock_Total)); } break; } } #endregion #region Search if (!string.IsNullOrEmpty(pageinfo.keyword)) { pageinfo.keyword = pageinfo.keyword.ToLower(); lstTmp = lstTmp.Where(o => (!string.IsNullOrEmpty(o.tensp) && o.tensp.Contains(pageinfo.keyword)) || (!string.IsNullOrEmpty(o.Barcode) && o.Barcode.Contains(pageinfo.keyword)) || (!string.IsNullOrEmpty(o.masp) && o.masp.Contains(pageinfo.keyword)) ); } #endregion min = Helpers.FindMin(pageinfo.pageindex, pageinfo.pagesize); count = lstTmp.Count(); if (!isSort) { lstTmp = lstTmp.OrderByDescending(o => o.DateCreate); } var result = lstTmp.Skip(min).Take(pageinfo.pagesize).ToList(); return(result); }
private void Main_Load(object sender, EventArgs e) { lblUserCurrent.Text = UserCurrent.getCurrentUser().Usuario; }