Example #1
0
        private void Search()
        {
            try
            {
                var opar = new BEArticle();
                var sortindex = gdvSearch.SortedColumns[0].VisibleIndex;
                if (sortindex == 0)
                    opar.ALF_CODI_ARTI = txtParameter.Text.Trim();
                else
                    opar.ALF_ARTI = txtParameter.Text.Trim();
                opar.COD_COMP = xfMain.SgIns.SESSION_COMP;

                var obr = new BRArticle();
                var olst = obr.Get_PSGN_SPLS_SVMC_ARTI(opar);

                gdcSearch.DataSource = olst;
                gdvSearch.MoveFirst();
            }
            catch (Exception ex)
            {
                XtraMessageBox.Show(ex.Message, WhMessage.MsgInsCaption,
                                    MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
Example #2
0
        public void Set_Save()
        {
            MessageBoxIcon msgIcon = MessageBoxIcon.Warning;
            try
            {
                var obar = new BEArticle();
                if (!string.IsNullOrWhiteSpace(txtCOD_ARTI.Text))
                    obar.COD_ARTI = Convert.ToInt32(txtCOD_ARTI.Text);
                obar.ALF_CODI_ARTI = txtALF_CODI_ARTI.Text.Trim();
                obar.ALF_ARTI = txtALF_ARTI.Text.Trim();
                obar.ALF_DESC = mmeALF_DESC.Text.Trim();
                obar.COD_TIPO_ARTI = Convert.ToInt32(lkeCOD_TIPO_ARTI.EditValue);
                obar.COD_MODE_ARTI = Convert.ToInt32(lkeCOD_MODE_ARTI.EditValue);
                obar.NUM_STOC_MINI = Convert.ToInt32(txtNUM_STOC_MINI.Text);
                if (pteIMG_FOTO.Image != null)
                    obar.IMG_FOTO = ImageToByteArray(pteIMG_FOTO.Image);
                obar.IND_MNTN = 1;
                if (!string.IsNullOrWhiteSpace(txtCOD_ARTI.Text))
                    obar.IND_MNTN = 2;
                obar.COD_USUA_CREA = SESSION_USER;
                obar.COD_USUA_MODI = SESSION_USER;
                obar.COD_COMP = SESSION_COMP;

                var context = new ValidationContext(obar, null, null);
                var errors = new List<ValidationResult>();
                if (!Validator.TryValidateObject(obar, context, errors, true))
                {
                    foreach (ValidationResult result in errors)
                    {
                        msgIcon = MessageBoxIcon.Warning;
                        throw new ArgumentException(result.ErrorMessage);
                    }
                }
                else
                {
                    var obr = new BRArticle();
                    obr.Set_PSWH_SPMT_SVMC_ARTI(obar);
                    if (!string.IsNullOrWhiteSpace(obar.MSG_MNTN))
                    {
                        msgIcon = MessageBoxIcon.Error;
                        throw new ArgumentException(obar.MSG_MNTN);
                    }
                    StateControls(true);
                    txtCOD_ARTI.Text = obar.COD_ARTI.ToString();
                    XtraMessageBox.Show(WhMessage.MsgSuccessfully,
                                        WhMessage.MsgInsCaption,
                                        MessageBoxButtons.OK,
                                        MessageBoxIcon.Information);
                }

            }
            catch (Exception ex)
            {
                XtraMessageBox.Show(ex.Message,
                                    WhMessage.MsgInsCaption,
                                    MessageBoxButtons.OK,
                                    msgIcon);
            }
        }
Example #3
0
        private void lsbPriceList_SelectedIndexChanged(object sender, EventArgs e)
        {
            var row = (BEPriceList)lsbPriceList.GetItem(lsbPriceList.SelectedIndex);
            if (row == null) return;
            txtCOD_LIST_PREC.Text = row.COD_LIST_PREC.ToString();
            txtALF_LIST_PREC.Text = row.ALF_LIST_PREC;
            rdgIND_TIPO_LIST.EditValue = row.IND_TIPO_LIST;

            var obr = new BRArticle();
            var olst = obr.Get_PSCP_SPLS_SVMD_LIST_PREC(row.COD_LIST_PREC);
            gdcDetail.DataSource = olst;
        }
Example #4
0
        private void xfPriceList_Load(object sender, EventArgs e)
        {
            SESSION_USER = ((xfMain)MdiParent).SESSION_USER;
            SESSION_PERF = ((xfMain)MdiParent).SESSION_PERF;
            SESSION_COMP = ((xfMain)MdiParent).SESSION_COMP;

            ClearControls();
            StateControls(true);

            var obr = new BRArticle();
            var olpl = obr.Get_PSCP_SPLS_SVMC_LIST_PREC(SESSION_COMP);
            lsbPriceList.DataSource = olpl;
            lsbPriceList.DisplayMember = "ALF_LIST_PREC";
            lsbPriceList.ValueMember = "COD_LIST_PREC";
            lsbPriceList.SelectedIndex = -1;
            lsbPriceList.UnSelectAll();

            gdcDetail.DataSource = new List<BEPriceListDetail>();
        }
Example #5
0
        public void Set_Save()
        {
            MessageBoxIcon msgIcon = MessageBoxIcon.Warning;
            try
            {
                var obpc = new BEPriceList()
                {
                    COD_LIST_PREC = (string.IsNullOrWhiteSpace(txtCOD_LIST_PREC.Text)) ? 0 : Convert.ToInt32(txtCOD_LIST_PREC.Text),
                    ALF_LIST_PREC = txtALF_LIST_PREC.Text.Trim(),
                    IND_TIPO_LIST = (int?)rdgIND_TIPO_LIST.EditValue,
                    COD_COMP = SESSION_COMP,
                    COD_USUA_CREA = SESSION_USER,
                    COD_USUA_MODI = SESSION_USER,
                    IND_MNTN = (string.IsNullOrWhiteSpace(txtCOD_LIST_PREC.Text)) ? 1 : 2
                };

                var context = new ValidationContext(obpc, null, null);
                var errors = new List<ValidationResult>();
                if (!Validator.TryValidateObject(obpc, context, errors, true))
                {
                    foreach (ValidationResult result in errors)
                    {
                        msgIcon = MessageBoxIcon.Warning;
                        throw new ArgumentException(result.ErrorMessage);
                    }
                }

                gdvDetail.CloseEditor();
                gdvDetail.RefreshData();
                var olst = (List<BEPriceListDetail>)gdvDetail.DataSource;
                if (olst.Count == 0)
                {
                    msgIcon = MessageBoxIcon.Warning;
                    throw new ArgumentException(WhMessage.MsgManyRows);
                }

                var i = 1;
                olst.ForEach(item =>
                {
                    context = new ValidationContext(item, null, null);
                    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 BRArticle();
                obr.Set_PSCP_SPMT_SVMC_LIST_PREC(obpc, olst);
                if (!string.IsNullOrWhiteSpace(obpc.MSG_MNTN))
                {
                    msgIcon = MessageBoxIcon.Error;
                    throw new ArgumentException(obpc.MSG_MNTN);
                }
                txtCOD_LIST_PREC.Text = obpc.COD_LIST_PREC.ToString();
                olst.RemoveAll(item => item.IND_MNTN == 3);
                olst.ForEach(item => { item.IND_MNTN = 0; });
                gdvDetail.RefreshData();
                StateControls(true);
                XtraMessageBox.Show(WhMessage.MsgSuccessfully, WhMessage.MsgInsCaption,
                                    MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            catch (Exception ex)
            {
                XtraMessageBox.Show(ex.Message,
                                    WhMessage.MsgInsCaption,
                                    MessageBoxButtons.OK,
                                    msgIcon);
            }
        }