Exemple #1
0
        private void Set_Operation(int index)
        {
            try
            {
                if (index == 0)
                {
                    gdvLines.CloseEditor();
                    gdvLines.RefreshData();
                    var olst = (List<BEDocumentLines>)gdvLines.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 BEDocumentLines() { COD_USUA_CREA = SESSION_USER };
                    olst.Add(obj);
                    gdvLines.RefreshData();
                    gdvLines.MoveLast();
                    gdvLines.FocusedColumn = gcALF_CODI_ARTI;
                    gdvLines.ShowEditor();
                }
                else
                {
                    gdvLines.DeleteRow(gdvLines.FocusedRowHandle);
                    gdvLines.RefreshData();
                }
                Set_Totals();
            }
            catch (Exception ex)
            {
                XtraMessageBox.Show(ex.Message,
                                    _Message.MsgInsCaption,
                                    MessageBoxButtons.OK,
                                    MessageBoxIcon.Warning);
            }
        }
Exemple #2
0
 private void Set_TotalLine(BEDocumentLines row)
 {
     row.NUM_PREC_DESC = row.NUM_PREC_UNIT - row.NUM_DESC;
     row.NUM_IMPO = row.NUM_CANT * row.NUM_PREC_DESC;
     gdvLines.RefreshRow(gdvLines.FocusedRowHandle);
 }
Exemple #3
0
        private void rpiArticle_ButtonClick(object sender, ButtonPressedEventArgs e)
        {
            var oxf = new xfSearchArticle();
            if (oxf.ShowDialog() == DialogResult.OK)
            {
                var olst = (List<BEDocumentLines>)gdvLines.DataSource;
                var exist = olst.Exists(item => item.COD_ARTI == oxf.rowsel.COD_ARTI);
                if (!exist)
                {
                    decimal TIP_CAMB = 1;
                    if (lkeCOD_MONE.ItemIndex == 1)
                    {
                        if (txtNUM_TIPO_CAMB.EditValue == null)
                            TIP_CAMB = ((xfMain)MdiParent).SESSION_NUM_TIPO_CAMB_COMP;
                    }
                    var row = new BEDocumentLines()
                    {
                        COD_ARTI = oxf.rowsel.COD_ARTI,
                        ALF_CODI_ARTI = oxf.rowsel.ALF_CODI_ARTI,
                        ALF_ARTI = oxf.rowsel.ALF_ARTI,
                        NUM_CANT = 1,
                        NUM_PREC_UNIT_ORIG = oxf.rowsel.NUM_PREC,
                        NUM_PREC_UNIT = Math.Round(oxf.rowsel.NUM_PREC * TIP_CAMB, 2),
                        NUM_PORC_DESC = oxf.rowsel.NUM_DESC,
                        COD_USUA_CREA = SESSION_USER
                    };

                    row.NUM_DESC = Math.Round((row.NUM_PREC_UNIT * row.NUM_PORC_DESC) / 100, 2);
                    row.NUM_PREC_DESC = row.NUM_PREC_UNIT - row.NUM_DESC;
                    row.NUM_IMPO = row.NUM_CANT * row.NUM_PREC_DESC;

                    gdvLines.DeleteRow(gdvLines.FocusedRowHandle);
                    olst.Add(row);
                    gdvLines.RefreshData();
                    gdvLines.MoveLast();
                    gdvLines.FocusedColumn = gcNUM_CANT;
                    gdvLines.ShowEditor();

                    Set_Totals();
                }
                else
                {
                    XtraMessageBox.Show(_Message.MsgExistArticle, _Message.MsgInsCaption,
                                        MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
            }
        }