예제 #1
0
    private void UpdateDataView()
    {
        UserList plUsers = PL.GetByKey(plCode).Users;

        vPLUsers = new CollectionView(plUsers);

        UserList users = HyperCatalog.Business.User.GetAll("IsActive = 1");

        if (users != null)
        {
            dg.DataSource = users;
            Utils.InitGridSort(ref dg, false);
            dg.DataBind();

            if (dg.Rows.Count > 0)
            {
                dg.Visible          = true;
                lbNoresults.Visible = false;
            }
            else
            {
                lbNoresults.Text    = "No user found";
                dg.Visible          = false;
                lbNoresults.Visible = true;
            }
        }
    }
예제 #2
0
 protected void UpdateDataView()
 {
     if (plCode != null)
     {
         PL p = PL.GetByKey(plCode);
         txtCode.Text              = p.Code;
         txtPath.Text              = p.Organization.Name + "/" + p.Group.Name + "/" + p.GBU.Name;
         txtName.Text              = p.Name;
         cbActive.Checked          = p.IsActive;
         cbActive.Enabled          = !cbActive.Checked;
         ddlBusName.DataSource     = getBusinesses().Tables[0];
         ddlBusName.DataTextField  = "BusinessName";
         ddlBusName.DataValueField = "BusinessId";
         ddlBusName.DataBind();
         ddlBusName.Items.Insert(0, new ListItem("--- Select ---", "0"));
         if (p.BusinessId.Trim() == "")
         {
             ddlBusName.SelectedIndex = 0;
             cbPMActive.Checked       = false;
         }
         else
         {
             ddlBusName.SelectedIndex = ddlBusName.Items.IndexOf(new ListItem(p.BusinessName.Trim(), p.BusinessId.Trim()));
             ddlBusName.Enabled       = false;
             cbPMActive.Checked       = true;
         }
         UITools.ShowToolBarButton(uwToolbar, "Save");
         if (!cbActive.Enabled)
         {
             //UITools.HideToolBarButton(uwToolbar, "Save");
             lbUsage.Text = "This PL is currently attached to item or input forms";
         }
     }
 }
예제 #3
0
        private void UpdateDataEdit(string selPLCode)
        {
            panelGrid.Visible = false;
            webTab.Tabs.GetTab(0).ContentPane.TargetUrl = "./pls/pl_properties.aspx?p=" + selPLCode;
            PL p = PL.GetByKey(selPLCode);

            lbTitle.Text           = "PL: [" + p.Code + "] " + p.Name;
            webTab.Tabs[1].Visible = true;
            webTab.Tabs.GetTab(1).ContentPane.TargetUrl = "./pls/pl_users.aspx?p=" + selPLCode;
            webTab.Visible         = true;
            webTab.Tabs[2].Visible = false;
        }
예제 #4
0
 private void ApplyChanges()
 {
     #region Remove all users attached to this PL
     using (Database dbObj = new Database(SessionState.CacheComponents["Crystal_DB"].ConnectionString, 240))
     {
         dbObj.RunSQLQuery("DELETE FROM UserPLs WHERE PLCode = '" + plCode + "'");
         #endregion
         if (dbObj.LastError != string.Empty)
         {
             lbError.Text     = "Error: impossible to remove all users - " + dbObj.LastError;
             lbError.CssClass = "hc_error";
             lbError.Visible  = true;
         }
         else
         {
             for (int i = 0; i < dg.Rows.Count; i++)
             {
                 TemplatedColumn col = (TemplatedColumn)dg.Rows[i].Cells.FromKey("Select").Column;
                 CheckBox        cb  = (CheckBox)((CellItem)col.CellItems[i]).FindControl("g_sd");
                 if (cb.Checked)
                 {
                     using (User u = HyperCatalog.Business.User.GetByKey(Convert.ToInt32(dg.Rows[i].Cells.FromKey("UserId").Value)))
                     {
                         u.PLs.Add(PL.GetByKey(plCode));
                         if (!u.Save(false, true))
                         {
                             lbError.Text     = "Error: impossible to add the user " + u.FullName + " to the PL " + plCode;
                             lbError.CssClass = "hc_error";
                             lbError.Visible  = true;
                             break;
                         }
                     }
                 }
             }
             UpdateDataView();
             lbError.Text     = "Changes applied";
             lbError.CssClass = "hc_success";
             lbError.Visible  = true;
         }
     }
 }
예제 #5
0
    private void Save()
    {
        if (ddlGBUName.SelectedIndex == 0)
        {
            logError("Please select valid GBU Name");
            return;
        }
        if (txtPLCode.Text.Trim() == "")
        {
            logError("Please enter PLCode");
            return;
        }
        if (txtPLName.Text.Trim() == "")
        {
            logError("Please enter PL Name");
            return;
        }
        if (chkPMActive.Checked)
        {
            if (!chkIsActive.Checked)
            {
                logError("Please select valid GBU Name");
                return;
            }
            if (ddlBusName.SelectedIndex == 0)
            {
                logError("Please select valid Business Name");
                return;
            }
        }
        if (PL.GetByKey(txtPLCode.Text.Trim()) != null)
        {
            logError("PL Code already exists");
            return;
        }
        if (txtPLCode.Text.Trim().Length > 2)
        {
            logError("Length of the PL Code should not be more than two.");
            return;
        }

        String insertQry = "INSERT INTO BPL SELECT DISTINCT OrgCode,GroupCode,GBUCode,'" + txtPLCode.Text.Trim() + "' AS 'PLCode',OrgName,GroupName,GBUName,'" + txtPLName.Text.Trim() + "' AS 'PLName','" + (chkIsActive.Checked?1:0).ToString() + "' AS 'IsActive',GETUTCDATE() AS 'ModifyDate' FROM BPL WHERE GBUCode = '" + ddlGBUName.SelectedValue.Trim() + "'";

        if (chkPMActive.Checked)
        {
            insertQry = insertQry + ";" + "INSERT INTO BusinessProductLines (BusinessId,PLCode,ModifyDate) VALUES ('" + ddlBusName.SelectedValue.Trim() + "','" + txtPLCode.Text.Trim() + "',GETUTCDATE())";
        }

        using (Database dbObj = Utils.GetMainDB())
        {
            dbObj.RunSQL(insertQry);
            dbObj.CloseConnection();
            if (dbObj.LastError.Length > 0)
            {
                logError(dbObj.LastError);
            }
            else
            {
                lbMsg.Text     = "Data saved!";
                lbMsg.CssClass = "hc_success";
                lbMsg.Visible  = true;
            }
        }
    }