/// <summary> /// Creates a new instance of this class. /// </summary> public DemoForm() { FormBorderStyle fbs = FormBorderStyle.None; string[] args = Environment.GetCommandLineArgs(); foreach (string arg in args) { if (arg.Length > 1 && arg[0] == '-') { foreach (char c in arg) { switch (c) { case 'g': _generateFakeData = true; break; case 'o': _offlineMode = true; break; case 'w': fbs = FormBorderStyle.Sizable; _bottomMargin = 48; _topMargin = 100; break; } } } } FormBorderStyle = fbs; InitializeComponent(); _fc = new FControl(); }
public static void AplicarSoloLectura(Control APadre) { foreach (Control FControl in APadre.Controls) { // Cuadros en sólo lectura if (FControl.GetType().ToString().Equals("System.Web.UI.WebControls.TextBox")) { ((TextBox)FControl).ReadOnly = true; } // Listas desplegables desactivadas if ((FControl.GetType().ToString().Equals("System.Web.UI.WebControls.DropDownList")) && (!FControl.ID.StartsWith("ddlNav"))) { ((DropDownList)FControl).Enabled = false; } // Casillas de verificación desactivadas if (FControl.GetType().ToString().Equals("System.Web.UI.WebControls.CheckBox")) { ((CheckBox)FControl).Enabled = false; } // Selección de archivos (estándar) if (FControl.GetType().ToString().Equals("System.Web.UI.WebControls.FileUpload")) { FControl.Visible = false; } // Selección de archivos (AJAX) if (FControl.GetType().ToString().Equals("AjaxControlToolkit.AsyncFileUpload")) { FControl.Visible = false; } // Calendarios (AJAX) if (FControl.GetType().ToString().Equals("AjaxControlToolkit.CalendarExtender")) { ((AjaxControlToolkit.CalendarExtender)FControl).Enabled = false; } // Ocultar/cambiar texto de botones if (FControl.GetType().ToString().Equals("System.Web.UI.WebControls.Button")) { Button FButton = ((Button)FControl); if (FButton.Text.Contains("Guardar")) { FButton.Visible = false; } if (FButton.Text.Contains("Aceptar")) { FButton.Visible = false; } if (FButton.Text.Contains("Agregar")) { FButton.Visible = false; } if (FButton.Text == "+") { FButton.Visible = false; } if (FButton.Text.Contains("Modificar")) { FButton.Text = "Abrir"; } if (FButton.Text.Contains("Eliminar")) { FButton.Visible = false; } if (FButton.Text.Contains("Seleccionar")) { FButton.Visible = false; } if (FButton.Text.Contains("Cancelar")) { FButton.Text = "Cerrar"; } } AplicarSoloLectura(FControl); } }
protected void Upload_Click(object sender, EventArgs e) { if (Allowed_Extension() == true) { try { con.Open(); string folderPath = Server.MapPath("~/Apps/" + appName.Text + "/"); int APPID; Random r = new Random(); do { APPID = r.Next(1, 100); cmd = new SqlCommand("select * from App where ID = " + APPID + ";", con); rd = cmd.ExecuteReader(); } while (rd.HasRows); //Select a unique ID from 1 to 100 rd.Close(); if (!Directory.Exists(folderPath)) { Directory.CreateDirectory(folderPath); string iconPath = Server.MapPath("~/Apps/" + appName.Text + "/" + "img/"); Directory.CreateDirectory(iconPath); string filename = ""; string iconname = ""; if (FControl.HasFile) { try { filename = Path.GetFileName(FControl.FileName); iconname = Path.GetFileName(IconControl.FileName); FControl.SaveAs(folderPath + filename); IconControl.SaveAs(iconPath + iconname); FileInfo fi = new FileInfo(Convert.ToString(folderPath + Path.GetFileName(FControl.FileName))); FileInfo ic = new FileInfo(Convert.ToString(folderPath + Path.GetFileName(IconControl.FileName))); long size = fi.Length / 1024; cmd.CommandText = "insert into App values(" + APPID + ",'" + appName.Text + "','" + Description.Text + "','" + getTypeFromExtension(fi.Extension) + "'," + size + ");" + "insert into AppLocation values(" + APPID + ",'" + fi.Name.ToString() + "');" + "insert into AppIcon values(" + APPID + ",'" + ic.Name.ToString() + "');"; cmd.ExecuteNonQuery(); foreach (ListItem listItem in Category.Items) { if (listItem.Selected) { cmd.CommandText = "insert into AppCategory values(" + APPID + "," + listItem.Value + ");"; cmd.ExecuteNonQuery(); } } con.Close(); StatusLabel.Text = "Upload Status: " + "File Uploaded"; } catch (Exception ex) { StatusLabel.Text = "Upload Status: Upload Failed. Reason: " + ex.Message; } } } else { StatusLabel.Text = "Upload Status: App Already Exists"; } } catch (Exception ex) { StatusLabel.Text += "Exception Occured. Reason:" + ex.Message; } } else { StatusLabel.Text = "Upload Status: Failed. Reason: Category and file type mismatched..."; } }