private void BindDropDownList() { Js.BLL.Account.UserDal dal = new Js.BLL.Account.UserDal(); Js.Model.Account.UsersInfo model = dal.GetModel(UserName); string filter = string.Format("UserName<>'administrator' and UserName<>'{0}' and ",UserName); if (model.UserLevel % 1000 == 0) filter += "UserLevel % 1000=0"; else filter += "UserLevel % 1000>0"; DataTable dt = dal.GetRecord(filter); this.ddlUserID.DataSource = dt; this.ddlUserID.DataTextField = "UserName"; this.ddlUserID.DataValueField = "UserID"; this.ddlUserID.DataBind(); }
protected void Page_Load(object sender, EventArgs e) { ID = Request.QueryString["ID"] + ""; FormID = Request.QueryString["FormID"] + ""; if (!IsPostBack) { ViewState["StrWhere"] = string.Format(" AnnounceID='{0}'", ID); if (Session["UserType"].ToString() == "BU") { this.txtAnnounceFlag.Text = Resources.Resource.AnnounceFlag1; Js.BLL.BusinessUnit.CompanyDal cdal = new Js.BLL.BusinessUnit.CompanyDal(); Js.Model.BusinessUnit.CompanyInfo model = cdal.GetModel(); this.txtAnnounceUnitNo.Text = model.CompanyNo; Js.BLL.Account.UserDal udal = new Js.BLL.Account.UserDal(); Js.Model.Account.UsersInfo umodel = udal.GetModel(Session["User"].ToString()); this.txtAnnouncer.Text = umodel.PersonName; } else { this.txtAnnounceFlag.Text = Resources.Resource.AnnounceFlag2; this.txtAnnounceUnitNo.Text = Session["EnterpriseID"].ToString(); Js.BLL.Account.UserDal udal = new Js.BLL.Account.UserDal(Session["EnterpriseID"].ToString()); Js.Model.Account.UsersInfo umodel = udal.GetModel(Session["User"].ToString()); this.txtAnnouncer.Text = umodel.PersonName; } Js.BLL.BaseDal dal = new Js.BLL.BaseDal(FormID); string strWhere = " AnnounceID like '" + this.txtAnnounceUnitNo.Text + DateTime.Now.ToString("yyyyMMdd") + "%'"; dal.GetMaxID(strWhere); this.txtAnnounceID.Text = dal.GetMaxID(strWhere); if(this.txtAnnounceID.Text.Length<=0) this.txtAnnounceID.Text =this.txtAnnounceUnitNo.Text + DateTime.Now.ToString("yyyyMMdd") + "0001"; this.txtAnnouncerUserName.Text = Session["User"].ToString(); this.txtSource.Text = Resources.Resource.AnnounceSource1; BindGrid(); } }
private void BindGrid() { this.GridView1.Columns[12].Visible = true; this.GridView1.Columns[13].Visible = true; this.GridView1.Columns[14].Visible = true; UserID = int.Parse(ViewState["UserID"].ToString()); string UserName = ViewState["UserName"].ToString(); int ParentUserID = int.Parse(ViewState["ParentUserID"].ToString()); string ParentUserName = ViewState["ParentUserName"].ToString(); Js.BLL.Account.UserDal dal = new Js.BLL.Account.UserDal(); Js.Model.Account.UsersInfo model = dal.GetModel(UserID); this.txtUserID.Text = model.UserID.ToString(); this.txtUserName.Text = model.UserName; this.txtTrueName.Text = model.TrueName; this.txtPersonID.Text = model.PersonID; this.txtPersonName.Text = model.PersonName; this.ddlDepartmentID.SelectedValue = model.DepartmentID; if (!model.Sex) this.ddlSex.SelectedIndex = 0; else this.ddlSex.SelectedIndex = 1; if (model.State == 0) this.txtState.Text = Resources.Resource.User_State0; else if (model.State == 1) this.txtState.Text = Resources.Resource.User_State1; else this.txtState.Text = Resources.Resource.User_State2; if (model.UserLevel == 1000) this.ddlUserLevel.SelectedIndex = 2; else if (model.UserLevel % 1000 == 0) this.ddlUserLevel.SelectedIndex = 1; else this.ddlUserLevel.SelectedIndex = 0; this.txtEnableDate.Text = Js.Com.PageValidate.ParseDateTime(model.EnableDate.ToString()); this.txtStopDate.Text = Js.Com.PageValidate.ParseDateTime(model.StopDate.ToString()); this.txtEMail.Text = model.Email; this.txtPhone.Text = model.Phone; this.txtCellPhone.Text = model.CellPhone; this.txtCreateDate.Text = Js.Com.PageValidate.ParseDateTime(model.CreateDate.ToString()); this.txtCreateUserName.Text = model.CreateUserName; this.txtLastModifyDate.Text = Js.Com.PageValidate.ParseDateTime(model.LastModifyDate.ToString()); this.txtLastModifyUserName.Text = model.LastModifyUserName; //用戶本身權限 dtUser = dal.GetUserPermission(UserID, UserName).Tables[0]; //父級用戶權限 DataTable dt; if (ViewState["ParentUserName"].ToString().ToLower() == "administrator" || ViewState["ParentUserName"].ToString() == "") dt = dal.GetPermission(Session["language_session"].ToString()).Tables[0]; else dt = dal.GetUserPermission(ParentUserID, ParentUserName).Tables[0]; this.GridView1.DataSource = dt; this.GridView1.DataBind(); this.GridView1.Columns[12].Visible = false; this.GridView1.Columns[13].Visible = false; this.GridView1.Columns[14].Visible = false; if (UserName.ToLower() == "administrator") { this.btnPermission.Enabled = false; this.btnDelete.Enabled = false; this.btnRole.Enabled = false; this.btnState.Enabled = false; } else { this.btnPermission.Enabled = true; this.btnDelete.Enabled = true; this.btnRole.Enabled = true; this.btnState.Enabled = true; } }
protected void btnState_Click(object sender, EventArgs e) { UserID = int.Parse(ViewState["UserID"].ToString()); Js.BLL.Account.UserDal dal = new Js.BLL.Account.UserDal(); dal.ChangeUserState(UserID); Js.Model.Account.UsersInfo model = dal.GetModel(UserID); if (model.State == 0) this.txtState.Text = Resources.Resource.User_State0; else if (model.State == 1) this.txtState.Text = Resources.Resource.User_State1; else this.txtState.Text = Resources.Resource.User_State2; this.txtEnableDate.Text = Js.Com.PageValidate.ParseDateTime(model.EnableDate.ToString()); this.txtStopDate.Text = Js.Com.PageValidate.ParseDateTime(model.StopDate.ToString()); }
public static void SystemMessage(string[] ToUserName, int ReceiverFlag, string[] ReceiveUnitNo, string Title, string Content) { Js.BLL.BaseDal dal = new Js.BLL.BaseDal("Sys_AnnounceMessage"); string strAnnounceUnitNo = ""; string strAnnounceID = ""; string strAnnouncer = ""; string strWhere = " AnnounceID like '" + strAnnounceUnitNo + DateTime.Now.ToString("yyyyMMdd") + "%'"; dal.GetMaxID(strWhere); strAnnounceID = dal.GetMaxID(strWhere); if (strAnnounceID.Length <= 0) strAnnounceID = strAnnounceUnitNo + DateTime.Now.ToString("yyyyMMdd") + "0001"; if (HttpContext.Current.Session["UserType"].ToString() == "BU") { Js.BLL.BusinessUnit.CompanyDal cdal = new Js.BLL.BusinessUnit.CompanyDal(); Js.Model.BusinessUnit.CompanyInfo model = cdal.GetModel(); strAnnounceUnitNo = model.CompanyNo; Js.BLL.Account.UserDal udal = new Js.BLL.Account.UserDal(); Js.Model.Account.UsersInfo umodel = udal.GetModel(HttpContext.Current.Session["User"].ToString()); strAnnouncer = umodel.PersonName; } else { strAnnounceUnitNo = HttpContext.Current.Session["EnterpriseID"].ToString(); Js.BLL.Account.UserDal udal = new Js.BLL.Account.UserDal(HttpContext.Current.Session["EnterpriseID"].ToString()); Js.Model.Account.UsersInfo umodel = udal.GetModel(HttpContext.Current.Session["User"].ToString()); strAnnouncer = umodel.PersonName; } DataTable dt = dal.GetRecord("1=2"); DataRow dr = dt.NewRow(); dr["AnnounceID"] = strAnnounceID; dr["Announcer"] = strAnnouncer; if (HttpContext.Current.Session["UserType"].ToString() == "BU") dr["AnnounceFlag"] = 0; else dr["AnnounceFlag"] = 1; dr["AnnounceUnitNo"] = strAnnounceUnitNo; dr["AnnouncerUserName"] = HttpContext.Current.Session["User"].ToString(); dr["Source"] = 1; dr["AnnounceDate"] = DateTime.Now; dr["Title"] = Title; dr["Contents"] = Content; dal.Add(dr); DataTable dtSub = dal.GetSubDetail("").Tables[0]; for (int i = 0; i < ToUserName.Length; i++) { DataRow subdr = dtSub.NewRow(); subdr["AnnounceID"] = strAnnounceID; subdr["ReceiverUserName"] = ToUserName[i]; subdr["ReceiverFlag"] = ReceiverFlag; subdr["ReceiveUnitNo"] = ReceiveUnitNo[i]; Js.BLL.Account.UserDal udal = new Js.BLL.Account.UserDal(ReceiveUnitNo[i]); Js.Model.Account.UsersInfo umodel = udal.GetModel(ToUserName[i]); subdr["Receiver"] = umodel.PersonName; dtSub.Rows.Add(subdr); } dal.SaveDetail(dtSub, ""); }