示例#1
0
 public void UpdateCodigoBarra(LinkarProdutoNotaFiscalDTO DTO)
 {
     try
     {
         var query = "UPDATE produto SET codigo_barra = '' WHERE codigo_barra = '" + DTO.Codigo_Barra + "'; UPDATE produto SET codigo_barra = '" + DTO.Codigo_Barra + "' WHERE id = '" + DTO.Id + "'";
         bd.Conectar();
         bd.ExecutarComandoSQL(query);
     }
     catch (Exception ex)
     {
         throw new Exception(ex.Message);
     }
 }
示例#2
0
        public bool isEmpty(LinkarProdutoNotaFiscalDTO DTO)
        {
            bool isempty = true;
            var  dt      = new DataTable();

            try
            {
                var query = "select codigo_barra from produto where id = '" + DTO.Id + "'";
                bd.Conectar();
                dt = bd.RetDataTable(query);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.ToString());
            }
            finally
            {
                if (dt.Rows.Count > 0 && dt.Rows[0]["codigo_barra"].ToString() != "")
                {
                    isempty = false;
                }
            }
            return(isempty);
        }
        private void BtnAdicionar_Click(object sender, RoutedEventArgs e)
        {
            var handle = grdItens.GetFocusedRow();

            dto = handle as LinkarProdutoNotaFiscalDTO;
            dto.Codigo_Barra = Codigo_Barra;
            if (!bll.isEmpty(dto))
            {
                var resultEmpty = CustomOKCancelMessageBox.Show("Este produto já está linkado!\nDeseja mesmo alterar o link?", "Atenção!", Window.GetWindow(this));
                if (resultEmpty == System.Windows.Forms.DialogResult.OK)
                {
                    bll.UpdateCodigoBarra(dto);
                    Codigo_Getac = dto.Id.ToString();
                    Descricao    = dto.Descricao;
                    Fabricante   = dto.Fabricante;
                    DialogResult = true;
                }
            }
            else
            {
                var result = CustomOKCancelMessageBox.Show("Deseja mesmo linkar o produto da nota fiscal com este produto do sistema?", "Atenção!", Window.GetWindow(this));
                if (result == System.Windows.Forms.DialogResult.OK)
                {
                    bll.UpdateCodigoBarra(dto);
                    Codigo_Getac = dto.Id.ToString();
                    Descricao    = dto.Descricao;
                    Fabricante   = dto.Fabricante;
                    DialogResult = true;
                }
            }


            //update codigo_barras set from dto
            //passa valores para variavel publica


            /*int[] handles = grdItens.GetSelectedRowHandles();
             * if (handles.Length > 0)
             * {
             *
             * }
             *
             *
             * new Thread(() =>
             * {
             *  Dispatcher.Invoke(new Action(() =>
             *  {
             *      wb = new WaitBox();
             *      wb.Owner = Window.GetWindow(this);
             *      wb.Show();
             *  }));
             *  syncEvent.Set();
             *  foreach (var rowHandle in handles)
             *  {
             *      Dispatcher.Invoke(DispatcherPriority.Background,
             *    new Action(() =>
             *    {
             *        var selectedItem = grdItens.GetRow(rowHandle) as AdicionarItemProjetoDTO;
             *        dto.Id = Convert.ToInt32(selectedItem.Id);
             *        dto.Atividade_Id = Atividade_Id;
             *        dto.Negocio_Id = Negocio_Id;
             *        dto.Anotacoes = selectedItem.Anotacoes;
             *        bll.Inserir(dto);
             *        grdItens.UnselectAll();
             *    }));
             *  }
             *  t1 = new Thread(WaitBoxLoad);
             *  t1.Start();
             * }).Start();*/
        }