示例#1
0
        private void Get_Load()
        {
            var obr = new BRTypeArticle();
            var olst = obr.Get_PSGN_SPLS_SVMC_TIPO_ARTI(xfMain.SgIns.SESSION_COMP);
            if (olst.Count == 0)
            {
                var obj = new BETypeArticle() { 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();
            }));
        }
示例#2
0
 /// <summary>
 /// Mantenimiento de tipos de artículo.
 /// Inserta, Modifica y Elimina
 /// </summary>
 public void Set_PSGN_SPMT_SVMC_TIPO_ARTI(BETypeArticle obej, List<BETypeArticle> 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_ARTI", item.COD_TIPO_ARTI,
                                                                                        item.ALF_TIPO_ARTI,
                                                                                        item.ALF_DESC,
                                                                                        item.COD_USUA_CREA,
                                                                                        item.COD_USUA_MODI,
                                                                                        item.IND_MNTN))
                 {
                     ocmd.CommandTimeout = 2000;
                     odb.ExecuteNonQuery(ocmd, obts);
                     item.COD_TIPO_ARTI = Convert.ToInt32(odb.GetParameterValue(ocmd, "@COD_TIPO_ARTI"));
                 }
             });
             obts.Commit();
         }
         catch (Exception ex)
         {
             obts.Rollback();
             obej.MSG_MNTN = ex.Message;
         }
         finally
         {
             ocn.Close();
         }
     }
 }
示例#3
0
        private void Set_Operation(int index)
        {
            try
            {
                if (index == 0)
                {
                    gdvGeneric.CloseEditor();
                    gdvGeneric.RefreshData();
                    var olst = (List<BETypeArticle>)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 BETypeArticle() { IND_MNTN = 1, COD_USUA_CREA = xfMain.SgIns.SESSION_USER };
                    olst.Add(obj);
                    gdvGeneric.RefreshData();
                    gdvGeneric.MoveLast();
                    gdvGeneric.FocusedColumn = gcALF_TIPO_ARTI;
                    gdvGeneric.ShowEditor();
                }
                else if (index == 1)
                {
                    var row = (BETypeArticle)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);
            }
        }
示例#4
0
        private void Set_Save()
        {
            MessageBoxIcon msgIcon = MessageBoxIcon.Warning;
            try
            {
                gdvGeneric.CloseEditor();
                gdvGeneric.RefreshData();
                var olst = (List<BETypeArticle>)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 BRTypeArticle();
                var obej = new BETypeArticle();
                obr.Set_PSGN_SPMT_SVMC_TIPO_ARTI(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);
            }
        }
示例#5
0
 /// <summary>
 /// Mantenimiento de tipos de artículo.
 /// Inserta, Modifica y Elimina
 /// </summary>
 public void Set_PSGN_SPMT_SVMC_TIPO_ARTI(BETypeArticle obej, List<BETypeArticle> olst)
 {
     oda.Set_PSGN_SPMT_SVMC_TIPO_ARTI(obej, olst);
     Dispose(false);
 }