Exemple #1
0
        private void createDropDown(ref HtmlTableCell c2, int i, BsField f, BsItemForm item)
        {
            DropDownList dl = new DropDownList();

            dl.ID = "txtCampo" + f.Id.ToString();
            dl.Attributes.Add("msgName", f.Name);
            dl.Attributes.Add("validar", f.Compulsory.ToString().ToLower());

            Business.BsItensField itens2 = new Business.BsItemField(f).GetObjects();
            for (int x = 0; x < itens2.Count; x++)
            {
                dl.Items.Insert(x, new ListItem(itens2[x].Value, itens2[x].Value + ""));
            }
            dl.Items.Insert(0, new ListItem("[Selecione]", "0"));

            if (item.Id > 0)
            {
                if (dl.Items.Contains(dl.Items.FindByValue(item.GFields.GetKey(f).Value)))
                {
                    dl.SelectedValue = item.GFields.GetKey(f).Value.Trim();
                }

                BsUser usr = BsUser.GetUserOn();
                if (usr != null && (item.User.Id != usr.Id && !usr.Admin))
                {
                    dl.Enabled = f.ExceptionsUser;
                }
            }

            c2.Controls.Add(dl);
        }
Exemple #2
0
        private void createCheckBox(ref HtmlTableCell c2, int i, BsField f, BsItemForm item)
        {
            HtmlTable    table = new HtmlTable();
            HtmlTableRow tr    = new HtmlTableRow();

            Business.BsItemField iten1 = new Business.BsItemField();
            iten1.Field.Id = f.Id;
            Business.BsItensField itens1 = iten1.GetObjects();

            for (int x = 0; x < itens1.Count; x++)
            {
                HtmlTableCell td  = new HtmlTableCell();
                HtmlTableCell td2 = new HtmlTableCell();
                td2.InnerText = itens1[x].Value;

                HtmlInputCheckBox cb = new HtmlInputCheckBox();
                cb.ID   = "txtCampo" + f.Id + "-" + x;
                cb.Name = "txtCampo" + f.Id;
                cb.Attributes.Add("msgName", f.Name);
                cb.Attributes.Add("validar", f.Compulsory.ToString().ToLower());
                cb.Value = itens1[x].Value;

                td.Controls.Add(cb);
                tr.Controls.Add(td);
                tr.Controls.Add(td2);

                if (item.Id > 0)
                {
                    string[] arrValues = item.GFields.GetKey(f).Value.Split(new Char[] { ',' });
                    for (int j = 0; j < arrValues.Length; j++)
                    {
                        if (cb.Value == arrValues[j].Replace("&nbsp;", ""))
                        {
                            cb.Checked = true;
                        }
                    }

                    BsUser usr = BsUser.GetUserOn();
                    if (usr != null && (item.User.Id != usr.Id && !usr.Admin))
                    {
                        cb.Disabled = !f.ExceptionsUser;
                    }
                }
            }

            table.Controls.Add(tr);
            c2.Controls.Add(table);
        }
Exemple #3
0
        private void createListBox(ref HtmlTableCell c2, int i, BsField f, BsItemForm item)
        {
            ListBox tl = new ListBox();

            tl.ID            = "txtCampo" + f.Id.ToString();
            tl.SelectionMode = ListSelectionMode.Multiple;
            tl.Attributes.Add("msgName", f.Name.ToString());
            tl.Attributes.Add("validar", f.Compulsory.ToString().ToLower());

            Business.BsItensField itens3 = new Business.BsItemField(f).GetObjects();
            for (int x = 0; x < itens3.Count; x++)
            {
                tl.Items.Insert(x, new ListItem(itens3[x].Value, itens3[x].Value + ""));
            }

            if (item.Id > 0)
            {
                for (int t = 0; t < tl.Items.Count; t++)
                {
                    string[] arrValues = item.GFields.GetKey(f).Value.Split(new Char[] { ',' });
                    for (int j = 0; j < arrValues.Length; j++)
                    {
                        if (tl.Items[t].Value == arrValues[j])
                        {
                            tl.Items[t].Selected = true;
                        }
                    }
                }

                BsUser usr = BsUser.GetUserOn();
                if (usr != null && (item.User.Id != usr.Id && !usr.Admin))
                {
                    tl.Enabled = f.ExceptionsUser;
                }
            }

            c2.Controls.Add(tl);
        }
Exemple #4
0
        private void createRadioButton(ref HtmlTableCell c2, int i, BsField f, BsItemForm item)
        {
            RadioButtonList rbu = new RadioButtonList();

            rbu.RepeatColumns   = 5;
            rbu.RepeatDirection = RepeatDirection.Horizontal;
            rbu.ID = "txtCampo" + f.Id.ToString();
            rbu.Attributes.Add("msgName", f.Name);
            rbu.Attributes.Add("validar", f.Compulsory.ToString());

            Business.BsItemField iten = new Business.BsItemField();
            iten.Field.Id = f.Id;
            Business.BsItensField itens = iten.GetObjects();
            for (int x = 0; x < itens.Count; x++)
            {
                rbu.Items.Insert(x, new ListItem(itens[x].Value, itens[x].Value + ""));
            }
            if (itens.Count > 0)
            {
                rbu.Items[0].Selected = true;
            }

            if (item.Id > 0)
            {
                if (rbu.Items.Contains(rbu.Items.FindByValue(item.GFields.GetKey(f).Value)))
                {
                    rbu.SelectedValue = item.GFields.GetKey(f).Value;
                }

                BsUser usr = BsUser.GetUserOn();
                if (usr != null && (item.User.Id != usr.Id && !usr.Admin))
                {
                    rbu.Enabled = f.ExceptionsUser;
                }
            }

            c2.Controls.Add(rbu);
        }
Exemple #5
0
        private void createTextBoxMulti(ref HtmlTableCell c2, int i, BsField f, BsItemForm item)
        {
            TextBox textMult = new TextBox();

            textMult.Width    = Unit.Pixel(400);
            textMult.Height   = Unit.Pixel(150);
            textMult.TextMode = TextBoxMode.MultiLine;
            textMult.ID       = "txtCampo" + f.Id.ToString();
            textMult.Attributes.Add("msgName", f.Name);
            textMult.Attributes.Add("validar", f.Compulsory.ToString().ToLower());

            if (item.Id > 0)
            {
                textMult.Text = item.GFields.GetKey(f).Value;
                BsUser usr = BsUser.GetUserOn();
                if (usr != null && (item.User.Id != usr.Id && !usr.Admin))
                {
                    textMult.Enabled = f.ExceptionsUser;
                }
            }

            c2.Controls.Add(textMult);
        }
Exemple #6
0
        private void setTextBox(ref HtmlTableRow tbRow, ref BsField f, ref BsItemForm item, ref string calendar, string sId, bool and)
        {
            TextBox t         = new TextBox();
            string  nameCampo = "txtCampo" + f.Id.ToString() + sId;

            t.ID        = nameCampo;
            t.Width     = Unit.Pixel(f.Size * 7);
            t.MaxLength = f.Size;
            t.Attributes.Add("validar", f.Compulsory.ToString().ToLower());
            t.Attributes.Add("msgName", f.Name);

            if (f.Mask.DesMask != "" && f.Mask.Id != 8)
            {
                t.Attributes.Add("onkeypress", "return formatValue( this , '" + f.Mask.DesMask + "' )");
            }
            else if (f.Mask.Id == 8)
            {
                t.Attributes.Add("onkeypress", "return Formata(this,20,event,2)");
            }

            if (item.Id > 0)
            {
                t.Text = item.GFields.GetKey(f).Value;
                BsUser usr = BsUser.GetUserOn();
                if (usr != null && (item.User.Id != usr.Id && !usr.Admin))
                {
                    t.Enabled = f.ExceptionsUser;
                }
            }

            if (and)
            {
                HtmlTableCell tbCelAnd = new HtmlTableCell();
                tbRow.Controls.Add(tbCelAnd);
                tbCelAnd.InnerHtml = "&nbsp;Até&nbsp;";
            }

            if (f.Mask.Id == 5)
            {
                t.Attributes.Add("isDate", "true");
                calendar += "addCalendar(\"c" + nameCampo + "\", \"" + f.Name + "\", \"" + nameCampo + "\", \"Form1\");";

                t.Attributes.Add("onblur", "dateValidate(this)");

                HtmlTableCell tbCel  = new HtmlTableCell();
                HtmlTableCell tbCel2 = new HtmlTableCell();

                tbRow.Controls.Add(tbCel);
                tbRow.Controls.Add(tbCel2);

                tbCel.Width = "1";
                tbCel.Controls.Add(t);
                tbCel2.Attributes.Add("style", "cursor:hand");
                tbCel2.Attributes.Add("onclick", "showCal('c" + nameCampo + "','Form1')");

                HtmlImage img = new HtmlImage();
                img.Src    = "../imagens/calendar.jpg";
                img.Border = 0;

                tbCel2.Controls.Add(img);
            }
            else
            {
                HtmlTableCell tbCel = new HtmlTableCell();
                tbRow.Controls.Add(tbCel);
                tbCel.Controls.Add(t);
            }
        }