Пример #1
0
        private void InitControl(long DocID)
        {
            UDS.Components.DocumentFlow df = new UDS.Components.DocumentFlow();

            SqlDataReader dr = null; //������������
            DataTable dt = null;

            try
            {

                df.GetStyleDescription(FlowID, 0, out dr);
                if (DocID > 0)
                    df.GetDocumentInfo(DocID, out dt);

                ht.Style["Left"] = "1px";
                ht.Style["Top"] = "1px";

                al.Clear();
                AddHeadlin();

                while (dr.Read())
                {
                    TextBox txt = new TextBox();

                    txt.ID = "txt" + dr["Field_Name"].ToString();
                    al.Add(dr["Field_Name"].ToString());

                    if (dr["MultiLine"].ToString() != "False")
                    {
                        txt.TextMode = TextBoxMode.MultiLine;
                    }
                    if ("d" == dr["Field_Type"].ToString())
                    {
                        txt.Attributes.Add("onfocus", "setday(this);");
                        txt.AutoPostBack = true;
                        // txt.Visible = false;
                        txt.ReadOnly = true;

                    }
                    txt.Height = Int32.Parse(dr["Height"].ToString());
                    txt.Width = Int32.Parse(dr["Width"].ToString());
                    txt.CssClass = "Input3";

                    if (DocID > 0)
                    {
                        if (dt.Rows.Count > 0)
                        {
                            txt.Text = dt.Rows[0][dr["Field_Name"].ToString()].ToString();
                        }
                        else
                        {
                            txt.Text = "������";
                        }
                    }
                    else
                    {
                        txt.Text = "";
                    }

                    TableCell tc = new TableCell();

                    if ("d" == dr["Field_Type"].ToString() || "c" == dr["Field_Type"].ToString() || "n" == dr["Field_Type"].ToString() || null == dr["Field_Type"].ToString())
                    {
                        //nothing to do
                        tc.Controls.Add(txt);
                    }
                    else
                    {
                        //txt.Visible = false;
                        bool isDdl = IsDdlControl(dr["Field_Type"].ToString());
                        if (isDdl)
                        {
                            txt.Width = 0;
                            tc.Controls.Add(txt);
                            string fieldID = dr["Field_Type"].ToString();
                            DataTable dtFieldValue = df.GetFieldValueList(int.Parse(fieldID));
                            DropDownList ddl = new DropDownList();
                            ddl.ID = "ddl" + dr["Field_Name"].ToString();
                            ddl.DataSource = dtFieldValue;
                            ddl.DataTextField = dtFieldValue.Columns["FieldValue_Name"].ToString();
                            ddl.DataValueField = dtFieldValue.Columns["FieldValue_Name"].ToString();

                            ddl.DataBind();

                            ddl.Items.Insert(0, new ListItem("��ѡ��", ""));
                            ddl.Attributes.Add("onchange", "javascript:setTextValue('" + txt.ID + "','" + ddl.ID + "');");
                            if (DocID > 0)
                            {
                                if (dt.Rows.Count > 0)
                                {
                                    //txt.Text = dt.Rows[0][dr["Field_Name"].ToString()].ToString();
                                    ddl.SelectedValue = dt.Rows[0][dr["Field_Name"].ToString()].ToString();
                                }

                            }

                            //onchange="javascript:setTimeout('__doPostBack(\'ddld\',\'\')', 0)" language="javascript"
                            tc.Controls.Add(ddl);
                        }
                        else
                        {
                            txt.Text = getAutoNumber(dr["Field_Type"].ToString());
                            txt.Text = txt.Text+DateTime.Now.Year.ToString()+ this.flowNumber.PadLeft(4,'0').ToString();

                            txt.ReadOnly = true;
                            if (DocID > 0)
                            {
                                if (dt.Rows.Count > 0)
                                {
                                    //txt.Text = dt.Rows[0][dr["Field_Name"].ToString()].ToString();
                                    txt.Text = dt.Rows[0][dr["Field_Name"].ToString()].ToString();
                                }

                            }
                            tc.Controls.Add(txt);
                        }

                    }
                    //tc.Controls.Add(txt);

                    TableRow tr = new TableRow();
                    TableCell tl = new TableCell();

                    Literal lt = new Literal();

                    lt.Text = dr["Example"].ToString();

                    if (FieldNum == 0 || dr["judged"].ToString() == "True")
                    {
                        RequiredFieldValidator rfv = new RequiredFieldValidator();
                        rfv.ControlToValidate = txt.ID;
                        rfv.ErrorMessage = "(*)";
                        rfv.Display = ValidatorDisplay.Dynamic;
                        rfv.EnableClientScript = true;

                        tc.Controls.Add(rfv);
                    }
                    //if (dr["judged"].ToString() == "True")
                    //{

                    //    RegularExpressionValidator rev = new RegularExpressionValidator();

                    //    rev.ErrorMessage = "�����";
                    //    rev.ControlToValidate = txt.ID;
                    //    rev.ValidationExpression = @"\d+";

                    //    rev.Display = ValidatorDisplay.Dynamic;

                    //    tc.Controls.Add(rev);

                    //}
                    if ("n" == dr["Field_Type"].ToString())
                    {

                        RegularExpressionValidator rev = new RegularExpressionValidator();

                        rev.ErrorMessage = "��д���֣�����λС��";
                        rev.ControlToValidate = txt.ID;
                        rev.ValidationExpression = @"^\d{1,10}(\.\d{2})?$";

                        rev.Display = ValidatorDisplay.Dynamic;

                        tc.Controls.Add(rev);

                    }
                    //if ("d" == dr["Field_Type"].ToString()) //�������ֶ���֤
                    //{
                    //    RegularExpressionValidator revDate = new RegularExpressionValidator();

                    //    revDate.ErrorMessage = "�����";
                    //    revDate.ControlToValidate = txt.ID;
                    //    revDate.ValidationExpression = @"\d+";

                    //    revDate.Display = ValidatorDisplay.Dynamic;

                    //    tc.Controls.Add(revDate);
                    //}

                    tc.Controls.Add(lt);

                    tl.Text = dr["Field_Description"].ToString() + ":";

                    if (dr["MultiLine"].ToString() != "False")
                        tl.VerticalAlign = VerticalAlign.Top;
                    else
                        tl.VerticalAlign = VerticalAlign.Middle;
                    tl.HorizontalAlign = HorizontalAlign.Right;

                    tr.Cells.Add(tl);
                    tr.Cells.Add(tc);
                    ht.Rows.Add(tr);

                    tc = null;
                    tl = null;
                    tr = null;

                    FieldNum += 1;

                }
            }
            finally
            {

                if (dr != null)
                {
                    dr.Close();
                }
                dr = null;
            }
            if (DocID > 0)
                AddAttach(DocID);

            AddAttachControl();
            AddProjectControl();
            AddControl();

            //=============================//
            //			�����ע
            //=============================//
            DataTable dtPostil;
            df.GetDocumentPostil(DocID, out dtPostil);

            if (dtPostil != null)
            {
                if (dtPostil.Rows.Count > 0)
                {
                    Table tb = new Table();
                    tb.CssClass = "GbText";
                    tb.Width = Unit.Percentage(98);
                    AddRow(tb, "�������");
                    AddPostitleHead(tb);

                    for (int i = 0; i < dtPostil.Rows.Count; i++)
                    {
                        AddRow(tb, dtPostil.Rows[i]["RealName"].ToString(), dtPostil.Rows[i]["Postil_Date"].ToString(), dtPostil.Rows[i]["Postil_Content"].ToString(), Int32.Parse(dtPostil.Rows[i]["Postil_Type"].ToString()), dtPostil.Rows[i]["FileName"].ToString(), dtPostil.Rows[i]["FileVisualPath"].ToString(), dtPostil.Rows[i]["UsedTime"].ToString());
                    }
                    AddTable(ht, tb);
                }
            }
            dtPostil = null;
        }