Beispiel #1
0
    protected void btnExport_Click(object sender, EventArgs e)
    {
        try
        {
            ErrorMsgLabel.Text = "";

            DataTable Dt;

            #region 檢查是否已匯入檔案

            if (Session["SYS203_" + PageTimeStamp.Value] != null)
            {
                Dt = (DataTable)Session["SYS203_" + PageTimeStamp.Value];
            }
            else
            {
                throw new Exception("請先匯入檔案");
            }

            #endregion

            string strPassword = string.Empty;
            string strCryPassword = string.Empty;

            SYSModel.CryptographyHelper Cry = new SYSModel.CryptographyHelper();
            SYSModel.MaintainUser BCO2 = new SYSModel.MaintainUser(ConnectionDB);

            for (int i = 0; i < Dt.Rows.Count; i++)
            {
                strPassword = Dt.Rows[i][0].ToString();
                strCryPassword = Cry.Encrypt(strPassword);

                ParameterList.Clear();
                ParameterList.Add(strPassword);

                dt_Result = BCO2.QuerySwitch(SYSModel.MaintainUser.QueryType.CODE,
                                               ParameterList
                                               );

                ParameterList.Clear();
                //舊值
                ParameterList.Add(dt_Result.Rows[0]["ID"]);
                ParameterList.Add(dt_Result.Rows[0]["CODE"]);
                ParameterList.Add(dt_Result.Rows[0]["NAME"]);
                ParameterList.Add(dt_Result.Rows[0]["CREATEDATE"]);
                ParameterList.Add(dt_Result.Rows[0]["CREATEUID"]);
                ParameterList.Add(dt_Result.Rows[0]["UPDATEDATE"]);
                ParameterList.Add(dt_Result.Rows[0]["UPDATEUID"]);
                ParameterList.Add(dt_Result.Rows[0]["ENABLE"]);
                ParameterList.Add(dt_Result.Rows[0]["PASSWORD"]);
                ParameterList.Add(dt_Result.Rows[0]["MEMO"]);

                //需要更新值
                DateTime processtime = DateTime.Now;
                ParameterList.Add(dt_Result.Rows[0]["NAME"]);
                ParameterList.Add(processtime);
                ParameterList.Add(Session["UID"].ToString());
                ParameterList.Add(strCryPassword);
                ParameterList.Add(dt_Result.Rows[0]["MEMO"]);

                int UpdateRecord = 0;
                UpdateRecord = BCO2.UpdateUser(ParameterList, null);

                if (UpdateRecord == 0)
                {
                    throw new Exception("更新失敗!");
                }

                //UpdateExcelRecords(strPassword, strCryPassword.Trim());
            }

            this.ErrorMsgLabel.Text = "匯入完成!";
            //DownLoadFile();

        }
        catch (Exception ex)
        {
            ErrorMsgLabel.Text = ex.Message;
        }
    }
Beispiel #2
0
    /// <summary>
    /// 查詢資料庫取得資料
    /// </summary> 
    private void databind()
    {
        try
        {
            SYSModel.MaintainUser BCO = new SYSModel.MaintainUser(ConnectionDB);

            ParameterList.Clear();
            ParameterList.Add(Session["UID"].ToString());

            dt_Result = BCO.QuerySwitch(SYSModel.MaintainUser.QueryType.CODE,
                                           ParameterList
                                           );
          
        }
        catch (Exception ex)
        {
            ErrorMsgLabel.Text = ex.Message;
        }
    }
Beispiel #3
0
    /// <summary>
    /// 繫結資料
    /// </summary>
    /// <param name=VirtualDataID></param>
    private void databind(FormViewMode fvm)
    {
        try
        {
            SYSModel.MaintainUser BCO = new SYSModel.MaintainUser(ConnectionDB);

            ParameterList.Clear();         
            if (Request["ID"] != null)
                ParameterList.Add(Request["ID"].ToString());
            else
                ParameterList.Add("0");


            dt_Result = BCO.QuerySwitch(SYSModel.MaintainUser.QueryType.ID,
                                           ParameterList
                                           );
            if (dt_Result.Rows.Count > 0)
            {
                this.hiddenID.Value = dt_Result.Rows[0]["ID"].ToString();

                FormView1.DataSource = dt_Result;
                FormView1.DataBind();

                if (dt_Result.Rows[0]["ENABLE"].ToString() == "0")
                {
                    ((Button)FormView1.FindControl("EditButton")).Visible = false;
                    ((Button)FormView1.FindControl("DeleteButton")).Visible = false;
                }

                LogHelper LOG = new LogHelper(ConnectionDB);
                ParameterList.Clear();
                ParameterList.Add("SYS04人員");//0
                ParameterList.Add(Session["UID"].ToString());//1
                ParameterList.Add("Q");//2
                ParameterList.Add(dt_Result.Rows[0]["CODE"].ToString());//3
                ParameterList.Add(Request.ServerVariables["Server_Name"]);//4

                LOG.AddSafeLog(ParameterList);
            }

            AuthorityControls(this);

            //ToolBarStatus
            switch (fvm)
            {
                case FormViewMode.Edit:
                    ToolBarStatus("edit");
                    TextBox txtname = ((TextBox)this.FormView1.FindControl("TextBoxCode").FindControl("TextBoxName"));
                    txtname.Visible = false;
                    break;
                case FormViewMode.Insert:
                    ToolBarStatus("insert");
                    break;
                case FormViewMode.ReadOnly:
                    ToolBarStatus("readonly");
                    TextBox txtname1 = ((TextBox)this.FormView1.FindControl("TextBoxCode").FindControl("TextBoxName"));
                    txtname1.Visible = false;
                    break;
            }
        }
        catch (Exception ex)
        {
            ErrorMsgLabel.Text = ex.Message;
        }

    }//databind