Example #1
0
        private void Get_Load()
        {
            var obr = new BRTypeReason();
            var olst = obr.Get_PSGN_SPLS_SVMC_TIPO_MOTI();
            if (olst.Count == 0)
            {
                var obj = new BETypeReason() { IND_MNTN = 1, COD_USUA_CREA = xfMain.SgIns.SESSION_USER };
                olst.Add(obj);
            }
            gdcGeneric.DataSource = olst;

            BeginInvoke(new MethodInvoker(() =>
            {
                gdvGeneric.MoveLast();
                gdvGeneric.FocusedColumn = gdvGeneric.VisibleColumns[1];
                gdvGeneric.ShowEditor();
            }));
        }
Example #2
0
 /// <summary>
 /// Mantenimiento de tipos de motivo.
 /// Inserta, Modifica y Elimina
 /// </summary>
 public void Set_PSGN_SPMT_SVMC_TIPO_MOTI(BETypeReason obej, List<BETypeReason> olst)
 {
     if (ocn.State == ConnectionState.Closed) ocn.Open();
     using (var obts = ocn.BeginTransaction())
     {
         try
         {
             DbCommand ocmd;
             olst.Where(item=>item.IND_MNTN != 0)
                 .ToList()
                 .ForEach(item =>
             {
                 using (ocmd = odb.GetStoredProcCommand("PSGN_SPMT_SVMC_TIPO_MOTI", item.COD_TIPO_MOTI,
                                                                                        item.ALF_TIPO_MOTI,
                                                                                        item.COD_USUA_CREA,
                                                                                        item.COD_USUA_MODI,
                                                                                        item.IND_MNTN))
                 {
                     ocmd.CommandTimeout = 2000;
                     odb.ExecuteNonQuery(ocmd, obts);
                     item.COD_TIPO_MOTI = Convert.ToInt32(odb.GetParameterValue(ocmd, "@COD_TIPO_MOTI"));
                 }
             });
             obts.Commit();
         }
         catch (Exception ex)
         {
             obts.Rollback();
             obej.MSG_MNTN = ex.Message;
         }
         finally
         {
             ocn.Close();
         }
     }
 }
Example #3
0
 /// <summary>
 /// Mantenimiento de tipos de motivo.
 /// Inserta, Modifica y Elimina
 /// </summary>
 public void Set_PSGN_SPMT_SVMC_TIPO_MOTI(BETypeReason obej, List<BETypeReason> olst)
 {
     oda.Set_PSGN_SPMT_SVMC_TIPO_MOTI(obej, olst);
     Dispose(false);
 }
Example #4
0
        private void Set_Operation(int index)
        {
            try
            {
                if (index == 0)
                {
                    gdvGeneric.CloseEditor();
                    gdvGeneric.RefreshData();
                    var olst = (List<BETypeReason>)gdvGeneric.DataSource;
                    var i = 1;
                    olst.ForEach(obej =>
                    {
                        var context = new ValidationContext(obej, null, null);
                        var errors = new List<ValidationResult>();
                        if (!Validator.TryValidateObject(obej, context, errors, true))
                        {
                            foreach (ValidationResult result in errors)
                                throw new ArgumentException(string.Format("{0}\nFila: {1}", result.ErrorMessage, i));
                        }
                        i++;
                    });

                    var obj = new BETypeReason() { IND_MNTN = 1, COD_USUA_CREA = xfMain.SgIns.SESSION_USER };
                    olst.Add(obj);
                    gdvGeneric.RefreshData();
                    gdvGeneric.MoveLast();
                    gdvGeneric.FocusedColumn = gcALF_TIPO_MOTI;
                    gdvGeneric.ShowEditor();
                }
                else if (index == 1)
                {
                    var row = (BETypeReason)gdvGeneric.GetRow(gdvGeneric.FocusedRowHandle);
                    if (row.IND_MNTN != 0 &&
                        row.IND_MNTN != 3)
                    {
                        gdvGeneric.DeleteRow(gdvGeneric.FocusedRowHandle);
                    }
                    else
                    {
                        row.COD_USUA_MODI = xfMain.SgIns.SESSION_USER;
                        row.IND_MNTN = 3;
                    }
                    gdvGeneric.RefreshData();
                }
                else
                {
                    gdvGeneric.CloseEditor();
                    gdvGeneric.RefreshData();
                    if (gdvGeneric.RowCount == 0) return;
                    using (var osfl = new SaveFileDialog
                    {
                        Title = WhMessage.MsgSelFile,
                        Filter = WhMessage.MsgFilExport,
                        ValidateNames = true
                    })
                    {
                        if (osfl.ShowDialog() != DialogResult.OK)
                            return;
                        gdvGeneric.ExportToXlsx(osfl.FileName);
                        if (XtraMessageBox.Show(WhMessage.MsgConExport, WhMessage.MsgInsCaption,
                            MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                            System.Diagnostics.Process.Start(osfl.FileName);
                    }
                }
            }
            catch (Exception ex)
            {
                XtraMessageBox.Show(ex.Message,
                                    WhMessage.MsgInsCaption,
                                    MessageBoxButtons.OK,
                                    MessageBoxIcon.Warning);
            }
        }
Example #5
0
        private void Set_Save()
        {
            MessageBoxIcon msgIcon = MessageBoxIcon.Warning;
            try
            {
                gdvGeneric.CloseEditor();
                gdvGeneric.RefreshData();
                var olst = (List<BETypeReason>)gdvGeneric.DataSource;
                var i = 1;
                olst.ForEach(item =>
                {
                    var context = new ValidationContext(item, null, null);
                    var errors = new List<ValidationResult>();
                    if (!Validator.TryValidateObject(item, context, errors, true))
                    {
                        foreach (ValidationResult result in errors)
                        {
                            msgIcon = MessageBoxIcon.Warning;
                            throw new ArgumentException(string.Format("{0}\nFila: {1}", result.ErrorMessage, i));
                        }
                    }
                    i++;
                });

                var obr = new BRTypeReason();
                var obej = new BETypeReason();
                obr.Set_PSGN_SPMT_SVMC_TIPO_MOTI(obej, olst);
                if (!string.IsNullOrWhiteSpace(obej.MSG_MNTN))
                {
                    msgIcon = MessageBoxIcon.Error;
                    throw new ArgumentException(obej.MSG_MNTN);
                }

                olst.RemoveAll(item => item.IND_MNTN == 3);
                olst.ForEach(item => item.IND_MNTN = 0);
                gdvGeneric.RefreshData();
                XtraMessageBox.Show(WhMessage.MsgSuccessfully,
                                    WhMessage.MsgInsCaption,
                                    MessageBoxButtons.OK,
                                    MessageBoxIcon.Information);
            }
            catch (Exception ex)
            {
                XtraMessageBox.Show(ex.Message,
                                    WhMessage.MsgInsCaption,
                                    MessageBoxButtons.OK,
                                    msgIcon);
            }
        }