Exemplo n.º 1
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            if (CurrentUser.RightIsAdmin || CurrentUser.HasFactoryAdminRole())
            {
                if (CurrentUser.RightCanDelete || CurrentUser.RightIsCurrentFactoryAdmin)
                {
                    buttonDelete.Visible = true;
                }
                else
                {
                    buttonDelete.Visible = false;
                }


                DataSet ds = new DataSet();

                #region 工厂数据绑定

                ds.ReadXml(Server.MapPath("..") + "\\ERPReportFactory.xml");
                dropDownListFactory.DataSource     = ds;
                dropDownListFactory.DataTextField  = "Name";
                dropDownListFactory.DataValueField = "Value";
                dropDownListFactory.DataBind();

                if (dropDownListFactory.Items.Count == 0)
                {
                    dropDownListFactory.Items.Add(new ListItem("暂无工厂", "0"));
                }
                else if (!CurrentUser.RightIsAdmin)
                {
                    for (int i = dropDownListFactory.Items.Count - 1; i >= 0; i--)
                    {
                        int tmpID = Convert.ToInt32(dropDownListFactory.Items[i].Value);
                        if (!CurrentUser.FactoryIDList.Contains(tmpID) || (CurrentUser.FactoryIDList.Contains(tmpID) && CurrentUser.UseTypeList[CurrentUser.FactoryIDList.IndexOf(tmpID)] == 0))
                        {
                            dropDownListFactory.Items.Remove(dropDownListFactory.Items[i]);
                        }
                    }
                }

                dropDownListFactory.SelectedIndex = 0;

                #endregion


                if (!string.IsNullOrEmpty(Request.QueryString["ID"]))
                {
                    labelTitle.Text = "修改ERP辅助功能";
                    int ID = Convert.ToInt32(Request.QueryString["ID"]);

                    dropDownListFactory.Enabled = false;
                    buttonCopy.Visible          = true;

                    InfoSysEntityTableAdapters.SQLReportTableAdapter sqlAdapter = new InfoSysEntityTableAdapters.SQLReportTableAdapter();

                    InfoSysEntity.SQLReportDataTable curTable = sqlAdapter.SelectByID(ID);
                    foreach (InfoSysEntity.SQLReportRow curRow in curTable.Rows)
                    {
                        textBoxName.Text    = curRow.SQLReportName;
                        textBoxShowURL.Text = (curRow.SQLReportShowURL.GetType() == typeof(DBNull)) ? "" : curRow.SQLReportShowURL;
                        dropDownListReportCate.SelectedValue = curRow.SQLReportCate.ToString();
                        dropDownListFactory.SelectedValue    = curRow.SQLReportFactory.ToString();
                        textBoxSortIndex.Text = curRow.SQLReportSortIndex.ToString();

                        rightTable = new InfoSysEntityTableAdapters.ERPAddinRightTableAdapter().GetDataBySQLReportID(curRow.SQLReportID);

                        break;
                    }
                }
                else
                {
                    buttonCopy.Visible   = false;
                    buttonDelete.Visible = false;
                }

                departmentDatabinding();
                rightTableDataBing();
            }
            else
            {
                FounderTecInfoSys.Common.PageGeneralAction.GoBackShowWarmingWindow("您没有权限查看此页面,开通权限请与管理员联系");
                Response.End();
            }
        }
    }
Exemplo n.º 2
0
    protected void buttonSave_Click(object sender, EventArgs e)
    {
        string strReportName = textBoxName.Text.Trim();
        string strShowURL    = textBoxShowURL.Text.Trim();

        if (strReportName.Equals(string.Empty))
        {
            FounderTecInfoSys.Common.PageGeneralAction.ShowWarmingWindow("功能名称不能为空");
            textBoxName.Focus();
            return;
        }



        int sortIndex  = Convert.ToInt32(textBoxSortIndex.Text);
        int factoryID  = Convert.ToInt32(dropDownListFactory.SelectedValue);
        int reportCate = Convert.ToInt32(dropDownListReportCate.SelectedValue);


        string strCreator = System.Web.HttpContext.Current.User.Identity.Name.Trim();

        DateTime dtTime = DateTime.Now;

        int reportStatus = Convert.ToInt32(radioButtonListReportStatus.SelectedValue);

        InfoSysEntityTableAdapters.ERPAddinRightTableAdapter rightAdapter = new InfoSysEntityTableAdapters.ERPAddinRightTableAdapter();
        int ID = 0;

        if (actionType.ToLower().Trim().Equals("normal") && !string.IsNullOrEmpty(Request.QueryString["ID"]))
        {
            ID = Convert.ToInt32(Request.QueryString["ID"]);

            if (new InfoSysEntityTableAdapters.SQLReportTableAdapter().UpdateQuery(strReportName, reportCate, "", "", "", "", strShowURL, reportStatus, strCreator, dtTime, "", "", 0, "", factoryID, sortIndex, 1, ID) > 0)
            {
                rightAdapter.DeleteQuery(ID);

                //Response.Redirect("InputAddinForm.aspx", true);
            }
            else
            {
                FounderTecInfoSys.Common.PageGeneralAction.ShowWarmingWindow("操作出现异常, 请稍后再试");
                return;
            }
        }
        else
        {
            ID = Convert.ToInt32(new InfoSysEntityTableAdapters.SQLReportTableAdapter().InsertQuery(strReportName, reportCate, "", "", "", "", strShowURL, reportStatus, strCreator, strCreator, dtTime, dtTime, "", "", 0, 0, "", factoryID, sortIndex, 1, 1));
            if (ID > 0)
            {
                Response.Write(strJSForRefresh);
                //Response.Redirect("InputAddinForm.aspx", true);
            }
            else
            {
                FounderTecInfoSys.Common.PageGeneralAction.ShowWarmingWindow("操作出现异常, 请稍后再试");
                return;
            }
        }

        if (ID > 0)
        {
            foreach (InfoSysEntity.ERPAddinRightRow curRow in rightTable.Rows)
            {
                rightAdapter.InsertQuery(ID, curRow.ERPAddinRightName, strCreator);
            }

            Response.Write(strJSForRefresh);
        }
        else
        {
            FounderTecInfoSys.Common.PageGeneralAction.ShowWarmingWindow("操作出现异常, 请稍后再试");
        }
    }