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