Пример #1
0
        private BsItemForm setObject(BsItemForm item_, DataRow dr_)
        {
            item_._id = Convert.ToInt32(dr_["idItemForm"]);

            item_.Form.Id    = Convert.ToInt32(dr_["idForm"]);
            item_.Form.Anexo = Convert.ToBoolean(dr_["anexo"]);

            item_.Folder.Id = Convert.ToInt32(dr_["idFolder"]);
            item_._date     = Convert.ToDateTime(dr_["data"]);

            item_.User.Id   = Convert.ToInt32(dr_["idUser"]);
            item_.User.Name = dr_["nameUser"].ToString();

            BsFields fds = new BsField(item_.Form).GetObjects();

            for (int i = 0; i < fds.Count; i++)
            {
                BsGenericItem gItem = new BsGenericItem();
                gItem.Value = dr_["campo" + fds[i].Id].ToString();
                if (fds[i].Type.Id == 3)
                {
                    if (dr_["campo" + fds[i].Id] != DBNull.Value)
                    {
                        gItem.Value = Convert.ToDateTime(gItem.Value).ToString("dd/MM/yyyy");
                    }
                    else
                    {
                        gItem.Value = Convert.ToDateTime("01/01/1911").ToString("dd/MM/yyyy");
                    }
                }
                item_.GFields.Add(fds[i].Id, gItem);
            }
            return(item_);
        }
Пример #2
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);
        }
Пример #3
0
 public void AddGroupsByItemForm(BsGroups gs_, BsItemForm item_)
 {
     if (item_.Id == 0 || item_.Form.Id == 0)
     {
         throw new Exception("id item ou form not found");
     }
     Database.DaGroups.DelGroupsByItemFormId(item_.Id, item_.Form.Id);
     for (int i = 0; i < gs_.Count; i++)
     {
         Database.DaGroups.AddGroupItemForm(gs_[i].Id, item_.Id, item_.Form.Id);
     }
 }
Пример #4
0
        public BsGroups GetObjectsByItensForm()
        {
            if (ItensForm.Count == 0 || ItensForm[0].Id == 0 || ItensForm[0].Form.Id == 0)
            {
                return(null);
            }
            DataTable dt = Database.DaGroups.GetGroupsByItensForm(
                _id,
                ItensForm[0].Form.Id,
                BsItemForm.ConvertToArrayItensForm(ItensForm)
                );

            return(addObjectsList(dt));
        }
Пример #5
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);
        }
Пример #6
0
        private string createTextBox(ref HtmlTableCell c2, int i, BsField f, BsItemForm item, bool activeSearch)
        {
            string       calendar = "";
            HtmlTable    tb       = new HtmlTable();
            HtmlTableRow tbRow    = new HtmlTableRow();

            setTextBox(ref tbRow, ref f, ref item, ref calendar, "", false);
            if (activeSearch && (f.Type.Id == 3 || f.Type.Id == 7 || f.Type.Id == 9))
            {
                setTextBox(ref tbRow, ref f, ref item, ref calendar, "-End", true);
            }

            tb.Border      = 0;
            tb.CellPadding = 0;
            tb.CellSpacing = 0;
            tb.Controls.Add(tbRow);
            c2.Controls.Add(tb);

            return(calendar);
        }
Пример #7
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);
        }
Пример #8
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);
        }
Пример #9
0
        private void Page_Load(object sender, System.EventArgs e)
        {
            if (!Business.BsUser.UserOn())
            {
                Response.Write("<script>alert( 'Sua sessão expirou!' );top.login();</script>");
                Response.End();
            }
            else
            {
                usr = Business.BsUser.GetUserOn();
            }

            if (Request["idForm"] != null)
            {
                Session["idForm"] = Request["idForm"];
            }
            form = new Business.BsForm(Convert.ToInt32("0" + Session["idForm"])).GetObject();

            if (Request["idFolder"] != null)
            {
                Session["idFolder"] = Request["idFolder"];
            }
            folder = new Business.BsFolder(Convert.ToInt32("0" + Session["idFolder"]));

            item = new Business.BsItemForm(Convert.ToInt32("0" + Request["idItemForm"]), form);

            if (!Page.IsPostBack)
            {
                if (Request["force"] == null)
                {
                    loadForm();
                }
                else
                {
                    forceDownload(item);
                }
            }
        }
Пример #10
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);
        }
Пример #11
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);
            }
        }
Пример #12
0
 public BsReviewForm(int id_, BsItemForm itemForm_)
 {
     _id       = id_;
     _itemForm = itemForm_;
 }
Пример #13
0
 public BsItensForm(BsItemForm item)
 {
     this.Add(item.Id, item);
 }