protected void Page_Load(object sender, EventArgs e) { EnterpriseID = Request.QueryString["EnterpriseID"] + ""; if (!IsPostBack) { Js.BLL.BusinessUnit.EnterpriseDal dal = new Js.BLL.BusinessUnit.EnterpriseDal(); DataTable dt = dal.GetModifyRecord(EnterpriseID); this.GridView1.DataSource = dt.DefaultView; this.GridView1.DataBind(); } }
protected void btnSave_Click(object sender, EventArgs e) { Js.BLL.BaseDal dal = new Js.BLL.BaseDal(FormID); DataTable dt = dal.GetRecord(ViewState["StrWhere"].ToString()); DataRow dr = dt.NewRow(); dr["EnterpriseID"] = this.txtEnterpriseID.Text; dr["CategoryID"] = this.ddlCategoryID.SelectedValue.ToString(); dr["EnterpriseName"] = this.txtEnterpriseName.Text; dr["EnterpriseEName"] = this.txtEnterpriseEName.Text; dr["EnterpriseSName"] = this.txtEnterpriseSName.Text; dr["UnionID"] = this.txtUnionID.Text; //dr["LabelFrom"] = this.rbtLabelFromYes.Checked; dr["President"] = this.txtPresident.Text; //dr["PresidentPost"] = this.txtPresidentPost.Text; dr["Phone"] = this.txtPhone.Text; dr["Fax"] = this.txtFax.Text; //dr["Contact"] = this.txtContact.Text; //dr["ContactPost"] = this.txtContactPost.Text; //dr["ContactPhone"] = this.txtContactPhone.Text; //dr["CellPhone"] = this.txtCellPhone.Text; //dr["Email"] = this.txtEmail.Text; dr["WebUrl"] = this.txtWebUrl.Text; dr["Address"] = this.txtAddress.Text; dr["ZipNo"] = this.txtZipNo.Text; byte ServiceYears; byte.TryParse(this.txtServiceYears.Text.Trim(), out ServiceYears); this.txtServiceYears.Text = ServiceYears.ToString(); dr["ServiceYears"] = ServiceYears; dr["EnableMonths"] = byte.Parse(this.ddlEnableMonths.Text); dr["Memo"] = this.txtMemo.Text.Trim(); dr["CreateUserName"] = this.txtCreateUserName.Text; dr["CreateDate"] = this.txtCreateDate.Text; dr["LastModifyUserName"] = Session["User"].ToString(); dr["LastModifyDate"] = DateTime.Now.ToString(Js.Com.User.strDateFormat); dr["CheckUserName"] = this.txtCheckUserName.Text; if (this.txtCheckDate.Text.Length > 0) dr["CheckDate"] = this.txtCheckDate.Text; if (ID.Length > 0) { Js.BLL.BusinessUnit.EnterpriseDal edal = new Js.BLL.BusinessUnit.EnterpriseDal(); Js.Model.BusinessUnit.EnterpriseInfo model = edal.GetModel(ID); if (ServiceYears != model.ServiceYears || this.ddlEnableMonths.Text != model.EnableMonths.ToString()) { edal.InsertModifyRecord(ID, ServiceYears, byte.Parse(this.ddlEnableMonths.Text)); } dal.Update(dr, ID); } else dal.Add(dr); ////同步更新企業庫裡的這筆資料 //Js.BLL.BaseDal edal = new Js.BLL.BaseDal("EP_Enterprise", this.txtEnterpriseID.Text); //if (edal.Exists(this.txtEnterpriseID.Text)) // edal.Update(dr,ID); //else // edal.Add(dr); DataTable dtSub1 = dal.GetSubDetail("").Tables[0]; DataTable newdtb = Js.Com.JsonHelper.Json2Dtb(this.HdnSubDetail1.Value); for (int i = 0; i < newdtb.Rows.Count; i++) { DataRow subdr = dtSub1.NewRow(); subdr["EnterpriseID"] = this.txtEnterpriseID.Text; for (int j = 0; j < newdtb.Columns.Count; j++) { subdr[newdtb.Columns[j].ColumnName] = newdtb.Rows[i][j]; } if (ID.Length > 0) { subdr["LastModifyDate"] = DateTime.Now.ToString(Js.Com.User.strDateFormat); subdr["LastModifyUserName"] = Session["User"].ToString(); } else { subdr["CreateUserName"] = this.txtCreateUserName.Text; subdr["CreateDate"] = this.txtCreateDate.Text; subdr["LastModifyDate"] = DateTime.Now.ToString(Js.Com.User.strDateFormat); subdr["LastModifyUserName"] = Session["User"].ToString(); } dtSub1.Rows.Add(subdr); } dal.SaveDetail(dtSub1, ID); //dtSub1.TableName = "EP_EnterpriseLinkMan"; //edal.SaveDetail(dtSub1, ID); Response.Redirect("EnterpriseView.aspx?FormID=" + Server.UrlEncode(FormID) + "&ID=" + Server.UrlEncode(this.txtEnterpriseID.Text)); }
protected void btnLogin_Click(object sender, EventArgs e) { if (Session["CheckCode"].ToString() != this.txtVerifyCode.Text.Trim()) { JScript.Instance.ShowMessage(this.updatePanel, Resources.Resource.InvalidCheckCode); return; } Js.BLL.BusinessUnit.EnterpriseDal dal = new Js.BLL.BusinessUnit.EnterpriseDal(); Js.Model.BusinessUnit.EnterpriseInfo model = dal.GetModel(this.txtEnterpriseID.Text.Trim()); if (model.EnterpriseName.Trim().Length <= 0) { JScript.Instance.ShowMessage(this.updatePanel, Resources.Resource.Login_Enterprise_NotExist); return; } cnKey = model.EnterpriseID; string userName = Js.Com.PageValidate.InputText(this.txtUserName.Text.Trim(), 30); string Password = Js.Com.PageValidate.InputText(this.txtUserPwd.Text.Trim(), 30); string UserCache = Convert.ToString(Cache[userName]); if (UserCache == null || UserCache == string.Empty || Cache[userName].ToString() == Page.Request.UserHostAddress) { UserPrincipal newUser = UserPrincipal.ValidateLogin(userName, Password, cnKey); if (newUser == null) { JScript.Instance.ShowMessage(this.updatePanel, Resources.Resource.LoginFailed + userName); ScriptManager.RegisterStartupScript(this.updatePanel, this.GetType(), "Reload", "checkwd_reload();", true); return; } else { UserDal currentUser = new UserDal(newUser, cnKey); Js.Model.Account.UsersInfo userModel = currentUser.GetModel(userName); Context.User = newUser; if (((SiteIdentity)User.Identity).TestPassword(Password, cnKey) == 0) { JScript.Instance.ShowMessage(this.updatePanel, Resources.Resource.InvalidPassword); } else { FormsAuthentication.SetAuthCookie(userName, false); Session["UserInfo"] = currentUser; Session["UserLevel"] = userModel.UserLevel; Session["UserType"] = "EP"; Session["User"] = userName; Session["EnterpriseID"] = model.EnterpriseID; Session["EnterpriseName"] = model.EnterpriseName; Session["cnKey"] = model.EnterpriseID; //Session["cnKey"] = "Enterprise"; if (Session["returnPage"] != null) { string returnpage = Session["returnPage"].ToString(); Session["returnPage"] = null; Response.Redirect(returnpage); } else { Response.Redirect("~/Start.aspx"); //Response.Write("<script>window.parent.location.href='Start.aspx';</script>"); } } } } else { JScript.Instance.ShowMessage(this.updatePanel, Resources.Resource.TheUserLogined); return; } }