private void Get_Load() { var obrtm = new BRTypeReason(); var oltm = obrtm.Get_PSGN_SPLS_SVMC_TIPO_MOTI(); rilCOD_TIPO_MOTI.DataSource = oltm; rilCOD_TIPO_MOTI.Columns.Clear(); var lkci = new LookUpColumnInfo("ALF_TIPO_MOTI", "Tipos de Motivo", 20); rilCOD_TIPO_MOTI.Columns.Add(lkci); rilCOD_TIPO_MOTI.DisplayMember = "ALF_TIPO_MOTI"; rilCOD_TIPO_MOTI.ValueMember = "COD_TIPO_MOTI"; var obr = new BRReason(); var olst = obr.Get_PSGN_SPLS_SVMC_MOTI(xfMain.SgIns.SESSION_COMP); if (olst.Count == 0) { var obj = new BEReason() { 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(); })); }
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(); })); }
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); } }