Example #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            this.deviceId       = Common.GetEncryptedQueryStringValue("deviceId", 0);
            LabelPageTitle.Text = (this.deviceId == 0) ? "New Device" : "Edit Device";
            PanelError.Visible  = false;

            Page.Form.DefaultFocus  = DropDownListDeviceType.ClientID;
            Page.Form.DefaultButton = ButtonSaveList.UniqueID;

            if (!IsPostBack)
            {
                DropDownListDeviceType.Focus();

                BindDeviceType();
                BindMobileNetwork();

                PanelMobile.Visible = false;
                PanelLaptop.Visible = false;

                ButtonSaveEdit.Visible = true;
                ButtonSaveNew.Visible  = true;

                if (ViewState["deviceId"] != null)
                {
                    this.deviceId = Convert.ToInt32(ViewState["deviceId"].ToString());
                }
                if (this.deviceId != 0)
                {
                    BindDevice();
                }
            }
        }
Example #2
0
 private void BindDeviceType()
 {
     DropDownListDeviceType.ClearSelection();
     DropDownListDeviceType.DataSource     = DeviceType.GetDeviceTypeList();
     DropDownListDeviceType.DataTextField  = "Description";
     DropDownListDeviceType.DataValueField = "DeviceTypeId";
     DropDownListDeviceType.DataBind();
     DropDownListDeviceType.Items.Insert(0, new ListItem("Please select", "0"));
 }
Example #3
0
        private void BindDevice()
        {
            try
            {
                Device device = Device.GetDeviceByDeviceId(this.deviceId);

                DropDownListDeviceType.ClearSelection();
                DropDownListDeviceType.Items.FindByValue(device.DeviceTypeId.ToString()).Selected = true;
                TextBoxDescription.Text = device.Description;
                TextBoxComment.Text     = device.Comment;

                if (Convert.ToInt32(device.DeviceTypeId) == 3 /*Laptop*/)
                {
                    PanelMobile.Visible = false;
                    PanelLaptop.Visible = true;

                    TextBoxSerial.Text = device.Serial;
                }

                if (Convert.ToInt32(device.DeviceTypeId) == 1 || Convert.ToInt32(device.DeviceTypeId) == 2)
                {
                    PanelMobile.Visible = true;
                    PanelLaptop.Visible = false;

                    DropDownListMobileNetwork.ClearSelection();
                    DropDownListMobileNetwork.Items.FindByValue(device.MobileNetworkId.ToString()).Selected = true;
                    TextBoxMobile.Text = device.Mobile;
                    TextBoxSIM.Text    = device.SIM;
                    TextBoxIMEI.Text   = device.IMEI;
                    TextBoxPUCK.Text   = device.PUCK;
                }
            }
            catch (System.Data.SqlClient.SqlException sqlEx)
            {
                for (int i = 0; i < sqlEx.Errors.Count; i++)
                {
                    LabelError.Text += (sqlEx.Errors[i].Message + "<br />");
                }
                PanelError.Visible = true;
            }
            catch (Exception exception)
            {
                LabelError.Text   += (exception.Message + "<br />");
                PanelError.Visible = true;
            }
        }