Example #1
0
        private void setData()
        {
            cUser   oUser = new cUser();
            DataSet ds = new DataSet();
            string  strMessage = string.Empty, strCriteria = string.Empty;

            try
            {
                strCriteria = " and UserID = '" + ViewState["userID"].ToString() + "' ";
                if (!oUser.SP_USER_SEL(strCriteria, ref ds, ref strMessage))
                {
                    lblError.Text = strMessage;
                }
                else
                {
                    if (ds.Tables[0].Rows.Count > 0)
                    {
                        #region get Data
                        hddUserID.Value           = ds.Tables[0].Rows[0]["UserID"].ToString();
                        txtperson_code.Text       = ds.Tables[0].Rows[0]["person_code"].ToString();
                        txtperson_name.Text       = ds.Tables[0].Rows[0]["person_thai_name"].ToString() + "  " + ds.Tables[0].Rows[0]["person_thai_surname"].ToString();
                        txtperson_group_name.Text = ds.Tables[0].Rows[0]["person_group_name"].ToString();
                        txtdirector_name.Text     = ds.Tables[0].Rows[0]["director_name"].ToString();
                        txtunit_name.Text         = ds.Tables[0].Rows[0]["unit_name"].ToString();
                        txtemail.Text             = ds.Tables[0].Rows[0]["email"].ToString();
                        txtloginname.Text         = ds.Tables[0].Rows[0]["loginname"].ToString();
                        hddusername.Value         = ds.Tables[0].Rows[0]["loginname"].ToString();
                        txtpassword.Text          = Cryptorengine.Decrypt(ds.Tables[0].Rows[0]["password"].ToString(), true);
                        string strBudget_type = ds.Tables[0].Rows[0]["budget_type"].ToString();
                        InitcboBudgetType();
                        if (cboBudget_type.Items.FindByValue(strBudget_type) != null)
                        {
                            cboBudget_type.SelectedIndex = -1;
                            cboBudget_type.Items.FindByValue(strBudget_type).Selected = true;
                        }
                        if (ds.Tables[0].Rows[0]["status"].ToString() == "Y")
                        {
                            chkStatus.Checked = true;
                        }
                        else
                        {
                            chkStatus.Checked = false;
                        }
                        InitcboUser_group();
                        cbouser_group.SelectedValue = ds.Tables[0].Rows[0]["user_group_code"].ToString();
                        txtUpdatedBy.Text           = ds.Tables[0].Rows[0]["UpdatedBy"].ToString();;
                        txtUpdatedDate.Text         = cCommon.CheckDate(ds.Tables[0].Rows[0]["UpdatedDate"].ToString());

                        #endregion
                    }
                }
            }
            catch (Exception ex)
            {
                lblError.Text = ex.Message.ToString();
            }
        }
Example #2
0
        protected bool SetUserProfile(string strUserName, string strPassword, ref string _strError)
        {
            bool      booResult = false;
            cUser     objUser   = new cUser();
            DataTable dt        = new DataTable();
            DataSet   ds        = new DataSet();
            string    strCriteria;
            string    strMessage         = string.Empty;
            string    strDecryptPassword = string.Empty;

            strCriteria = " And LoginName='" + strUserName + "' ";
            objUser.SP_USER_SEL(strCriteria, ref ds, ref strMessage);
            dt = ds.Tables[0];
            if (dt.Rows.Count > 0)
            {
                strDecryptPassword = Cryptorengine.Decrypt(Helper.CStr(dt.Rows[0]["Password"]), true);
                if (strDecryptPassword.Equals(strPassword))
                {
                    this.IsLogin       = "******";
                    this.UserID        = Helper.CInt(dt.Rows[0]["UserID"]);
                    this.UserLoginName = Helper.CStr(dt.Rows[0]["LoginName"]);
                    this.DirectorLock  = Helper.CStr(dt.Rows[0]["director_lock"]);
                    this.DirectorCode  = Helper.CStr(dt.Rows[0]["director_code"]);
                    this.DirectorName  = Helper.CStr(dt.Rows[0]["director_name"]);

                    try
                    {
                        this.UnitLock = Helper.CStr(dt.Rows[0]["unit_lock"]);
                    }
                    catch
                    {
                        this.UnitLock = "N";
                    }

                    if (this.UnitLock == "Y")
                    {
                        this.UnitCodeList = string.Empty;
                        string[] strunit_code_list = Helper.CStr(dt.Rows[0]["unit_code_list"]).Split(',');
                        for (int i = 0; i <= (strunit_code_list.GetUpperBound(0)); i++)
                        {
                            this.UnitCodeList += "'" + strunit_code_list[i].Substring(3, 5) + "',";
                        }
                        this.UnitCodeList = this.UnitCodeList.Substring(0, this.UnitCodeList.Length - 1);
                    }

                    this.myBudgetType = Helper.CStr(dt.Rows[0]["budget_type"]);
                    string[] strperson_group_list = Helper.CStr(dt.Rows[0]["person_group_list"]).Split(',');
                    for (int i = 0; i <= (strperson_group_list.GetUpperBound(0)); i++)
                    {
                        PersonGroupList = PersonGroupList + "'" + strperson_group_list[i] + "',";
                    }
                    PersonGroupList = PersonGroupList.Substring(0, PersonGroupList.Length - 1);

                    cItem     objItem = new cItem();
                    DataTable dt2     = new DataTable();
                    DataSet   ds2     = new DataSet();
                    string    strYear = ((DataSet)Application["xmlconfig"]).Tables["default"].Rows[0]["yearnow"].ToString();
                    strCriteria  = " And person_group_code in (" + PersonGroupList + ") And lot_code<>'' ";
                    strCriteria += " And item_year = " + strYear;
                    objItem.SP_ITEM_LOT_GROUP_SEL(strCriteria, ref ds2, ref strMessage);
                    LotCodeList = string.Empty;
                    for (int i = 0; i < ds2.Tables[0].Rows.Count; i++)
                    {
                        LotCodeList = LotCodeList + "'" + ds2.Tables[0].Rows[i]["lot_code"].ToString() + "',";
                    }
                    if (LotCodeList.Length > 0)
                    {
                        LotCodeList = LotCodeList.Substring(0, LotCodeList.Length - 1);
                    }
                    booResult = true;
                }
                else
                {
                    _strError = "รหัสผ่านไม่ถูกต้อง";
                }
            }
            else
            {
                _strError = "ไม่พบผู้ใช้งานนี้";
            }
            return(booResult);
        }