Exemplo n.º 1
0
        private String GetID(XmlAttributeCollection xac, LayoutFieldEnum lfe, int LayoutFieldID)
        {
            String xID = String.Empty;

            foreach (XmlAttribute xa in xac)
            {
                if (xa.Name.Equals("id", StringComparison.OrdinalIgnoreCase))
                {
                    xID = xa.Value;
                    break;
                }
            }

            if (string.IsNullOrEmpty(xID) && LayoutFieldID > 0)
            {
                if (lfe == LayoutFieldEnum.ASPDNSFImageField)
                {
                    xID = "Image_" + LayoutFieldID.ToString();
                }
                else if (lfe == LayoutFieldEnum.ASPDNSFTextField)
                {
                    xID = "Text_" + LayoutFieldID.ToString();
                }
                else
                {
                    xID = "Unknown_" + LayoutFieldID.ToString();
                }
            }

            return(xID);
        }
Exemplo n.º 2
0
 private String GetID(XmlAttributeCollection xac, LayoutFieldEnum lfe)
 {
     return(GetID(xac, lfe, 0));
 }
Exemplo n.º 3
0
        private String WriteFieldToDB(LayoutFieldEnum lfe, XmlAttributeCollection xac, int LayoutID)
        {
            String fieldID = String.Empty;

            int LayoutFieldID = 0;

            using (SqlConnection conn = new SqlConnection(DB.GetDBConn()))
            {
                conn.Open();

                using (SqlCommand scom = new SqlCommand())
                {
                    scom.CommandType = CommandType.StoredProcedure;
                    scom.Connection  = conn;
                    scom.CommandText = "dbo.aspdnsf_insLayoutField";

                    scom.Parameters.Add(new SqlParameter("@LayoutID", SqlDbType.Int));
                    scom.Parameters.Add(new SqlParameter("@FieldType", SqlDbType.Int));
                    scom.Parameters.Add(new SqlParameter("@FieldID", SqlDbType.NVarChar));
                    scom.Parameters.Add(new SqlParameter("@LayoutFieldID", SqlDbType.Int, 4)).Direction = ParameterDirection.Output;

                    scom.Parameters["@LayoutID"].Value  = LayoutID;
                    scom.Parameters["@FieldType"].Value = lfe;

                    fieldID = GetID(xac);

                    scom.Parameters["@FieldID"].Value = fieldID;


                    try
                    {
                        scom.ExecuteNonQuery();
                        LayoutFieldID = Int32.Parse(scom.Parameters["@LayoutFieldID"].Value.ToString());

                        // they didn't specify an ID in the html that was uploaded or entered
                        // create one for them.
                        if (string.IsNullOrEmpty(fieldID) && LayoutFieldID != 0)
                        {
                            fieldID = GetID(xac, lfe, LayoutFieldID);

                            DB.ExecuteSQL("update dbo.LayoutField set FieldID=" + DB.SQuote(fieldID) + " where LayoutFieldID=" + LayoutFieldID.ToString());

                            //WriteLayoutFieldAttribute(conn, LayoutID, LayoutFieldID, "ID", fieldID);
                        }
                    }
                    catch { }
                }

                if (LayoutFieldID != 0)
                {
                    foreach (XmlAttribute xa in xac)
                    {
                        if (xa.Name.Equals("ID", StringComparison.OrdinalIgnoreCase) && (xa.Value.Length == 0 || !xa.Value.Equals(fieldID, StringComparison.OrdinalIgnoreCase)))
                        {
                            xa.Value = fieldID;
                        }

                        if (!xa.Name.Equals("type", StringComparison.OrdinalIgnoreCase))
                        {
                            WriteLayoutFieldAttribute(conn, LayoutID, LayoutFieldID, xa.Name, xa.Value);
                        }
                    }
                }
                conn.Close();
                conn.Dispose();
            }

            return(fieldID);
        }