using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using HySoft.Common;
namespace HySoft.BaseCallCenter.Web.sysmanage
{
public partial class usermodify : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
if (Request.QueryString["actionFlag"].ToString() == "edit")
{
getOrderInformerEdit(Request.QueryString["singleFlage"].ToString());
}
}
}
///
/// 初始化信息
///
private void getOrderInformerEdit(string Flage)
{
DataTable dt = new DataTable();
DataTable dtItems = new DataTable();
string sql = "select * from T_Sys_UserAccount where F_UserId=" + Flage + "";
dt = DBUtility.DbHelperSQL.Query(sql).Tables[0];
if (dt.Rows.Count > 0)
{
F_UserName.Text = dt.Rows[0]["F_UserName"].ToString();
hfbirthday.Value = dt.Rows[0]["F_Password"].ToString();
F_UserCode.Text = dt.Rows[0]["F_UserCode"].ToString();
hfRoleText.Value = dt.Rows[0]["F_RoleId"].ToString();
hfDeptText.Value = dt.Rows[0]["F_DeptId"].ToString();
if (dt.Rows[0]["F_SeatFlag"].ToString() == "True")
{
hdradiolist.Value = "1";
}
else
{
hdradiolist.Value = "0";
}
hfzuoxiquanxian.Value = dt.Rows[0]["F_SeatRight"].ToString();
hfzuoxileixing.Value = dt.Rows[0]["F_HJType"].ToString();
if (dt.Rows[0]["F_SexFlag"].ToString() == "男")
{
hfxinbie.Value = "1";
}
else
{
hfxinbie.Value = "0";
}
hfF_GroupId.Value = dt.Rows[0]["F_GroupId"].ToString();
txtExtNo.Text = dt.Rows[0]["F_ExtensionNumber"].ToString();
txtWorkNumber.Text = dt.Rows[0]["F_WorkNumber"].ToString();
txtBirthday.Text = dt.Rows[0]["F_Birthday"].ToString();
txtTelphone.Text = dt.Rows[0]["F_Telephone"].ToString();
txtMobel.Text = dt.Rows[0]["F_Mobile"].ToString();
txtRemark.Text = dt.Rows[0]["F_Remark"].ToString();
}
}
///
/// 保存用户方法
///
///
///
protected void btnSubmit_Click(object sender, EventArgs e)
{
try
{
string struserId = Request.QueryString["singleFlage"].ToString();
int userId = 0;
HySoft.BaseCallCenter.Model.T_Sys_UserAccount userAccountModel = new Model.T_Sys_UserAccount();
if (int.TryParse(struserId, out userId))
userAccountModel = new BLL.T_Sys_UserAccount().GetModel(userId);
HySoft.BaseCallCenter.BLL.T_Sys_UserAccount sysUserAccountBll = new BLL.T_Sys_UserAccount();
userAccountModel.F_UserCode = F_UserCode.Text.Trim();
userAccountModel.F_UserName = F_UserName.Text.Trim();
userAccountModel.F_Password = hfbirthday.Value;
userAccountModel.F_ExtensionNumber = txtExtNo.Text.Trim();
userAccountModel.F_WorkNumber = txtWorkNumber.Text.Trim();
userAccountModel.F_DeptId = Convert.ToInt32(hfDeptText.Value);
userAccountModel.F_RoleId = Convert.ToInt32(hfRoleText.Value);
if (hfF_GroupId.Value != "")
{
userAccountModel.F_GroupId = Convert.ToInt32(hfF_GroupId.Value);
}
if (hdradiolist.Value == "0")
{
userAccountModel.F_SeatFlag = false;
}
if (hdradiolist.Value == "1")
{
userAccountModel.F_SeatFlag = true;
}
userAccountModel.F_SeatRight = hfzuoxiquanxian.Value;
if (hfxinbie.Value == "1")
{
userAccountModel.F_SexFlag = "男";
}
else
{
userAccountModel.F_SexFlag = "女";
}
userAccountModel.F_Remark = txtRemark.Text;
userAccountModel.F_Mobile = txtMobel.Text;
userAccountModel.F_Telephone = txtTelphone.Text;
DateTime dttime = new DateTime();
bool b = DateTime.TryParse(txtBirthday.Text, out dttime);
if (b)
userAccountModel.F_Birthday = Convert.ToDateTime(txtBirthday.Text);
userAccountModel.F_CreateOn = DateTime.Now;
userAccountModel.F_DeleteFlag = 0;
userAccountModel.F_HJType = Convert.ToInt32(hfzuoxileixing.Value);
if (Request.QueryString["actionFlag"].Trim() == "edit")
{
DataTable dt = sysUserAccountBll.GetList("F_UserCode='" + F_UserCode.Text.Trim() + "' and F_UserId!=" + Request.QueryString["singleFlage"] + "").Tables[0];
if (dt.Rows.Count > 0)
{
MessageBoxToWindow("当前员工工号存在,请更换!", "提示", "error");
}
else
{
userAccountModel.F_UserId = Convert.ToInt32(Request.QueryString["singleFlage"]);
if (sysUserAccountBll.Update(userAccountModel))
{
MessageBoxToWindow("修改成功", "修改提示!", "success");
}
else
{
MessageBoxToWindow("修改失败", "修改提示!", "error");
}
}
}
}
catch (Exception ex)
{
SysLog.WriteLog(ex);
MessageBoxToWindow("异常提示!" + ex.Message, "提示", "catch");
}
}
#region 弹出对话框
///
/// 弹出对话框
///
///
///
///
public void MessageBoxToWindow(string title, string content, string type)
{
string script = "";
switch (type)
{
case "error"://失败
type = "error";
script = "";
break;
case "success"://成功
type = "info";
script = "";
break;
case "catch"://异常
type = "warning";
script = "";
break;
default:
type = "question";
break;
}
ClientScript.RegisterClientScriptBlock(this.GetType(), "", script);
}
#endregion
}
}