Beispiel #1
0
        private void Delete()
        {
            Caixa caixa = new Caixa
            {
                CaixaId = id
            };

            var exe = CaixaAppConstrutor.CaixaAppDO();

            try
            {
                exe.Delete(caixa);
                LimaprCampos();
                txtAviso.Text     = "Eliminado com succeso";
                smsAviso.IsActive = true;
                tmWarning.Start();
            }
            catch
            {
                txtAviso.Text     = "ocorreu um erro!";
                smsAviso.IsActive = true;
                tmWarning.Start();
            }
        }
Beispiel #2
0
        private void Save()
        {
            if (txtValorInicial.Text.Trim() == string.Empty)
            {
                txtAviso.Text = "Preencha o o valor inicial";
                tmWarning.Start();
            }
            else
            {
                if (txtValorActual.Text.Trim() == string.Empty)
                {
                    txtAviso.Text = "Preencha o valor actual.";
                    tmWarning.Start();
                }
                else
                {
                    if (dtOpen.Text.Trim() == string.Empty)
                    {
                        dtOpen.SelectedDate = DateTime.Now;
                    }
                    else
                    {
                        if (dtClose.Text.Trim() == string.Empty || dtClose.SelectedDate < dtOpen.SelectedDate)
                        {
                            dtClose.SelectedDate = DateTime.Now;
                        }
                        else
                        {
                            if (hrOpen.Text.Trim() == string.Empty)
                            {
                                hrOpen.SelectedTime = DateTime.Now;
                            }
                            else
                            {
                                if (hrClose.Text.Trim() == string.Empty)
                                {
                                    hrClose.SelectedTime = DateTime.Now;
                                }
                                else
                                {
                                    try
                                    {
                                        Caixa caixa = new Caixa
                                        {
                                            HoraAbertura = Convert.ToDateTime(dtOpen.SelectedDate.Value.ToShortDateString() + " " + hrOpen.SelectedTime.Value.ToLongTimeString()),
                                            HoraFecho    = Convert.ToDateTime(dtClose.SelectedDate.Value.ToShortDateString() + " " + hrClose.SelectedTime.Value.ToLongTimeString()),
                                            ValorInicial = txtValorInicial.Text.Trim(),
                                            ValorActual  = txtValorActual.Text.Trim(),
                                            UserId       = 3
                                        };

                                        var exe = CaixaAppConstrutor.CaixaAppDO();

                                        exe.Save(caixa);
                                        LimaprCampos();
                                        txtAviso.Text     = "Guardado com succeso";
                                        smsAviso.IsActive = true;
                                        tmWarning.Start();
                                    }
                                    catch
                                    {
                                        txtAviso.Text     = "ocorreu um erro!";
                                        smsAviso.IsActive = true;
                                        tmWarning.Start();
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }