예제 #1
0
        /*
         * private void CreateTypeValidationScript(string workstationTypeCtlID, string trolleyCtlID)
         * {
         *  ClientScript
         *      .RegisterClientScriptBlock(
         *          this.GetType(),
         *          "typeDropdownScript",
         *          "function CheckType()" +
         *          "{" +
         *          "    if (document.getElementById('" +
         *              workstationTypeCtlID + "').value != '" + WorkstationType.PS.ToString() + "')" +
         *          "    {" +
         *          "        document.getElementById('" +
         *                  trolleyCtlID + "').style.visibility = 'hidden';" +
         *          "        var combo = $find('" + trolleyCtlID + "');" +
         *          "        " +
         *          "        var comboItem = combo.findItemByText('item');" +
         *          "        if (comboItem){" +
         *          "        }else{" +
         *          "         comboItem= new Telerik.Web.UI.RadComboBoxItem();" +
         *          "         comboItem.set_text('item');" +
         *          "         comboItem.set_value('0');" +
         *          "         combo.trackChanges();" +
         *          "         combo.get_items().add(comboItem);" +
         *          "         comboItem.select(); " +
         *          "         combo.commitChanges();}" +
         *          "    }" +
         *          "    else" +
         *          "    {" +
         *          "          var combo = $find('" + trolleyCtlID + "');" +
         *          "          var items = combo.get_items();" +
         *          "          var comboItem = combo.findItemByText('item');" +
         *          "          if (comboItem)" +
         *          "          {" +
         *          "              combo.trackChanges();" +
         *          "              items.remove(comboItem);" +
         *          "              combo.commitChanges();" +
         *          "          }" +
         *          "          document.getElementById('" +
         *                      trolleyCtlID + "').style.visibility = 'visible';" +
         *          "    }" +
         *          "}", true);
         * }
         */
        protected void workstationGrid_ItemDataBound(object sender, GridItemEventArgs e)
        {
            if (e.Item is GridEditableItem && (e.Item as GridEditableItem).IsInEditMode)
            {
                DataSet dropdownSource = new DataSet();

                GridEditableItem editedItem = e.Item as GridEditableItem;

                SNumCodeDAO sNumCodeDAO = new SNumCodeDAO();

                //workstation type
                dropdownSource = sNumCodeDAO
                                 .GetCodesByType(SNumcodeType.MDS_WORKSTATION_TYPE.ToString());

                RadComboBox workstationType = (RadComboBox)editedItem
                                              .FindControl("workstation_type_RadComboBox");

                TextBox workstationLabel = (TextBox)editedItem.FindControl("workstation_label");

                workstationType
                .DataSource = dropdownSource
                              .Tables[SNumcodeType.MDS_WORKSTATION_TYPE.ToString()];

                workstationType.DataTextField = "char_short_translation";

                workstationType.DataValueField = "code";

                workstationType.DataBind();
                workstationType.Items.Insert(0, new RadComboBoxItem("", "0"));

                //workstation status
                dropdownSource = sNumCodeDAO
                                 .GetCodesByType(SNumcodeType.MDS_WORKSTATION_STATUS.ToString());

                RadComboBox workstationStatus = (RadComboBox)editedItem
                                                .FindControl("workstation_status_RadComboBox");

                workstationStatus.DataSource = dropdownSource
                                               .Tables[SNumcodeType.MDS_WORKSTATION_STATUS.ToString()];

                workstationStatus.DataTextField = "char_short_translation";

                workstationStatus.DataValueField = "code";

                workstationStatus.DataBind();
                workstationStatus.Items.Insert(0, new RadComboBoxItem("", "0"));


                //is international
                RadComboBox isInternational = (RadComboBox)editedItem
                                              .FindControl("international_ind_RadComboBox");

                isInternational.Items.Add(new RadComboBoxItem("Yes", "T"));
                isInternational.Items.Add(new RadComboBoxItem("No", "F"));


                isInternational.DataBind();
                isInternational.SelectedValue = "F";

                /****/
                ////trolley
                //TrolleyDAO trolleyDAO = new TrolleyDAO();
                //dropdownSource = trolleyDAO.Search_trolley();

                //RadComboBox trolley = (RadComboBox)editedItem
                //                        .FindControl("trolley_label_RadComboBox");

                //trolley.DataSource = dropdownSource.Tables[0];
                //trolley.DataTextField = "trolley_label";
                //trolley.DataValueField = "trolley_id";
                //trolley.DataBind();
                //trolley.Items.Insert(0, new RadComboBoxItem("", "0"));



                //Register script for status validation
                //CreateTypeValidationScript(workstationType.ClientID, trolley.ClientID);

                //In case is edit,
                //pre populate the fields with the record being edited
                _workstation = null;
                if (e.Item.ItemIndex != -1)
                {
                    int workstationID = int.Parse(
                        editedItem
                        .OwnerTableView
                        .DataKeyValues[e.Item.ItemIndex]["workstation_id"]
                        .ToString());

                    _workstationDAO = new PackstationDAO();

                    _workstation = _workstationDAO.GetWorkstationByID(workstationID);


                    workstationType.SelectedValue   = _workstation.Type.ToString();
                    workstationStatus.SelectedValue = _workstation.Status.ToString();
                    isInternational.SelectedValue   = _workstation.IsInternational.ToString();

                    /****/
                    //trolley.SelectedValue = _workstation.TrolleyID.ToString();
                }
                else
                {
                    workstationLabel.Text = Shared.UserHostName.Substring(0, Shared.UserHostName.IndexOf('.') - 1);
                }
            }
        }
예제 #2
0
        protected void deviceGrid_ItemDataBound(object sender, GridItemEventArgs e)
        {
            if (e.Item is GridEditableItem && (e.Item as GridEditableItem).IsInEditMode)
            {
                GridEditableItem editedItem = e.Item as GridEditableItem;

                //get all device types
                DataSet dropdownSource = new DataSet();

                SNumCodeDAO sNumCodeDAO = new SNumCodeDAO();


                dropdownSource = sNumCodeDAO
                                 .GetCodesByType(SNumcodeType.MDS_DEVICE_TYPE.ToString());

                RadComboBox deviceType = (RadComboBox)editedItem
                                         .FindControl("device_type_RadComboBox");

                RadComboBox deviceName = (RadComboBox)editedItem.FindControl("rcbName");

                if (e.Item.ItemIndex < 0)
                {
                    DeviceDAO devDAO = new DeviceDAO();

                    DataTable dtTemp = devDAO.GetDevices().Tables[0].Select("device_type <> 'CT'").CopyToDataTable();

                    deviceName.DataTextField  = "device_name";
                    deviceName.DataValueField = "device_name";

                    deviceName.DataSource = dtTemp;
                    deviceName.DataBind();
                }


                deviceType
                .DataSource = dropdownSource
                              .Tables[SNumcodeType.MDS_DEVICE_TYPE.ToString()];

                deviceType.DataTextField = "char_short_translation";

                deviceType.DataValueField = "code";

                deviceType.DataBind();

                deviceType.Items.Insert(0, new RadComboBoxItem("", "0"));


                //workstations
                WorkstationDAO deviceDAO = new PackstationDAO();

                dropdownSource = deviceDAO.GetWorkstations();

                RadComboBox workstationLabel = (RadComboBox)editedItem
                                               .FindControl("workstation_label_RadComboBox");
                RequiredFieldValidator RequiredFieldValidator2 = (RequiredFieldValidator)editedItem
                                                                 .FindControl("RequiredFieldValidator2");

                workstationLabel.DataSource = dropdownSource.Tables["mds_workstation"];

                workstationLabel.DataTextField = "workstation_label";

                workstationLabel.DataValueField = "workstation_id";

                workstationLabel.DataBind();

                workstationLabel.Items.Insert(0, new RadComboBoxItem("", "0"));

                //users
                //UserDAO userDAO = new UserDAO();

                //dropdownSource = userDAO.GetUsers();

                //RadComboBox username = (RadComboBox)editedItem
                //                                .FindControl("username_RadComboBox");

                //username.DataSource = dropdownSource.Tables["tblusers"];
                //username.DataTextField = "displayname";
                //username.DataValueField = "userid";
                //username.DataBind();
                //username.Items.Insert(0, new RadComboBoxItem("", "0"));


                //Register script for status validation
                CreateStatusValidationScript(deviceType.ClientID, workstationLabel.ClientID);

                _device = null;
                if (e.Item.ItemIndex != -1)
                {
                    int deviceID = int.Parse(
                        editedItem
                        .OwnerTableView
                        .DataKeyValues[e.Item.ItemIndex]["device_id"]
                        .ToString());

                    _deviceDAO = new DeviceDAO();

                    _device = _deviceDAO.GetDeviceByID(deviceID);


                    deviceType.SelectedValue       = _device.Type.ToString();
                    workstationLabel.SelectedValue = _device.WorkstationId.ToString();
                    //username.SelectedValue = _device.CurrentUser.ToString();
                }
            }
        }