//// GET: ShowItem //public ActionResult Index() //{ // string idstr = Request.QueryString["id"]; // int id = 0; // if (idstr == null || !Int32.TryParse(idstr, out id)) // { // return View("error"); // } // LayoutViewModel masterModel = new LayoutViewModel(db); // ArticleContent model = db.ArticleContents.Find(id); // // 根据不同的类型可以把title改下 // AcTypeEmun typeEnum = (AcTypeEmun)Enum.Parse((typeof(AcTypeEmun)), model.ACType); // string emumtext = RemarkAttribute.GetEnumRemark(typeEnum); // ViewBag.Title = "吉家尚" + emumtext + "详情页"; // ViewBag.Content = model.AContent; // masterModel.groupBuilds = db.ArticleContents // .Where(w => w.ACType == AcTypeEmun.GROUPBUILD.ToString().ToUpper()) // .Take(4).OrderBy(o => new { o.ACSortNum, o.InDateTime }) // .OrderBy(o => o.ACSortNum).ToList(); // return View(masterModel); //} /// <summary> /// 热门套餐,经典案例,团装,家居设计,环保装修详情页 /// </summary> /// <returns></returns> public ActionResult ArticleContent() { string idstr = Request.QueryString["id"]; int id = 0; if (idstr == null || !Int32.TryParse(idstr, out id)) { return(View("error")); } ArticleContent model = db.ArticleContents.Find(id); if (model == null) { return(View("error")); } // 根据不同的类型可以把title改下 AcTypeEmun typeEnum = (AcTypeEmun)Enum.Parse((typeof(AcTypeEmun)), model.ACType); string emumtext = RemarkAttribute.GetEnumRemark(typeEnum); ViewBag.Title = "吉家尚" + emumtext + "详情页"; ViewBag.Content = model.AContent; LayoutViewModel masterModel = new LayoutViewModel(db); masterModel.groupBuilds = db.ArticleContents .Where(w => w.ACType == AcTypeEmun.GROUPBUILD.ToString().ToUpper()) .Take(4).OrderBy(o => new { o.ACSortNum, o.InDateTime }) .OrderBy(o => o.ACSortNum).ToList(); return(View(masterModel)); }
public static string GetRemark(this Enum enumValue) { Type type = enumValue.GetType(); //1:获取字段的特性 RemarkAttribute attr = type.GetField(enumValue.ToString()).GetCustomAttribute(typeof(RemarkAttribute), true) as RemarkAttribute; if (attr == null) { return(enumValue.ToString()); } return(attr.Remark); }
// GET: ArticleContents/Details/5 public ActionResult Details() { string idnum = Request.QueryString["id"]; int id = 0; if (!Int32.TryParse(idnum, out id)) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } ArticleContent articleContent = db.ArticleContents.Find(id); if (articleContent == null) { return(HttpNotFound()); } AcTypeEmun typeEnum = AcTypeEmun.ROLL; typeEnum = (AcTypeEmun)Enum.Parse((typeof(AcTypeEmun)), articleContent.ACType); string emumtext = RemarkAttribute.GetEnumRemark(typeEnum); ViewBag.TypeText = emumtext; ViewBag.TypeNum = (int)typeEnum; ViewBag.Content = articleContent.AContent; articleContent.ACType = emumtext; string pagenum = "_"; if (typeEnum == AcTypeEmun.GROUPBUILD || typeEnum == AcTypeEmun.HOMEDESIGN || typeEnum == AcTypeEmun.ENVIRONMENTAL) { pagenum += "4"; } else { pagenum += ((int)typeEnum).ToString(); } if (typeEnum == AcTypeEmun.CLASSCASE) { foreach (var item in db.Designers) { if (articleContent.DId == item.Id) { ViewBag.DesignerName = item.DName + "_" + item.DUniversity + "_" + item.DDepartment; } } } return(View("Details" + pagenum, articleContent)); }
public ActionResult Create() { string typestr = Request.QueryString["type"]; int type = 0; if (typestr == null || !Int32.TryParse(typestr, out type) || !Enum.IsDefined(typeof(AcTypeEmun), type)) { return(View("error")); } if (type.Equals("0")) { return(View("error")); } ViewBag.TypeText = RemarkAttribute.GetEnumRemark((AcTypeEmun)type); ViewBag.TypeNum = type; string pagenum = "_"; if (type == (int)AcTypeEmun.GROUPBUILD || type == (int)AcTypeEmun.HOMEDESIGN || type == (int)AcTypeEmun.ENVIRONMENTAL) { pagenum += "4"; } else { pagenum += type.ToString(); } int designerListCount = 0; List <SelectListItem> designerList = new List <SelectListItem>(); if (type == (int)AcTypeEmun.CLASSCASE) { foreach (var item in db.Designers) { designerList.Add(new SelectListItem() { Text = item.DName + "_" + item.DUniversity + "_" + item.DDepartment, Value = item.Id.ToString() }); } designerListCount = db.Designers.Count(); } ViewData["DesignerList"] = designerList; ViewBag.DesignerListCount = designerListCount; return(View("Create" + pagenum)); }
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { DataRowView dv = e.Row.DataItem as DataRowView; Literal ltlSex = e.Row.Cells[3].FindControl("ltlSex") as Literal; if (Convert.ToInt32(dv[TB_EmployeeCheckIn.col_Sex]) == (int)TypeManager.Sex.Male) { ltlSex.Text = RemarkAttribute.GetEnumRemark(TypeManager.Sex.Male); } else if (Convert.ToInt32(dv[TB_EmployeeCheckIn.col_Sex]) == (int)TypeManager.Sex.Female) { ltlSex.Text = RemarkAttribute.GetEnumRemark(TypeManager.Sex.Female); } } }
// GET: ArticleContents public ActionResult Index() { string typestr = Request.QueryString["type"]; int type = 0; if (typestr == null || !Int32.TryParse(typestr, out type) || !Enum.IsDefined(typeof(AcTypeEmun), type)) { return(View("error")); } if (type.Equals("0")) { return(View("error")); } ViewBag.TypeText = RemarkAttribute.GetEnumRemark((AcTypeEmun)type); ViewBag.TypeNum = type; var list = new List <ArticleContent>(); string pagenum = "_"; AcTypeEmun typeEnum = (AcTypeEmun)type; string enumText = RemarkAttribute.GetEnumRemark(typeEnum); if (typeEnum == AcTypeEmun.GROUPBUILD || typeEnum == AcTypeEmun.HOMEDESIGN || typeEnum == AcTypeEmun.ENVIRONMENTAL) { pagenum += "4"; } else { pagenum += type.ToString(); } if (!db.ArticleContents.Any()) { return(View("Index" + pagenum, list)); } list = db.ArticleContents .Where(w => w.ACType == ((AcTypeEmun)type).ToString()) .OrderBy(o => new { o.ACSortNum, o.InDateTime }) .ToList(); if (list.Any()) { list.ForEach(f => { f.ACType = enumText; }); } return(View("Index" + pagenum, list)); }
public static void Main() { Type t = typeof(UseAttrib); Console.Write("Атрибуты в " + t.Name + ": "); object[] attribs = t.GetCustomAttributes(false); foreach (object o in attribs) { Console.WriteLine(o); } Console.Write("Remark: "); // Считываем атрибут RemarkAttribute. Type tRemAtt = typeof(RemarkAttribute); RemarkAttribute ra = (RemarkAttribute) Attribute.GetCustomAttribute(t, tRemAtt); Console.WriteLine(ra.remark); }
static void Main() { Type t = typeof(UseAttrib); Console.Write("Attributes in " + t.Name + ": "); object[] attribs = t.GetCustomAttributes(false); foreach (object o in attribs) { Console.WriteLine(o); } Console.Write("Remark: "); // Retrieve the RemarkAttribute. Type tRemAtt = typeof(RemarkAttribute); RemarkAttribute ra = (RemarkAttribute) Attribute.GetCustomAttribute(t, tRemAtt); Console.WriteLine(ra.Remark); }
// GET: ArticleContents/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } ArticleContent articleContent = db.ArticleContents.Find(id); if (articleContent == null) { return(HttpNotFound()); } ViewBag.TypeText = RemarkAttribute.GetEnumRemark((AcTypeEmun)Enum.Parse(typeof(AcTypeEmun), articleContent.ACType)); int type = (int)Enum.Parse(typeof(AcTypeEmun), articleContent.ACType); ViewBag.TypeNum = type; ViewBag.TypeEmnu = articleContent.ACType.ToString(); string pagenum = "_"; if (type == (int)AcTypeEmun.GROUPBUILD || type == (int)AcTypeEmun.HOMEDESIGN || type == (int)AcTypeEmun.ENVIRONMENTAL) { pagenum += "4"; } else { pagenum += type.ToString(); } if (type == (int)AcTypeEmun.CLASSCASE) { foreach (var item in db.Designers) { if (articleContent.DId == item.Id) { ViewBag.DesignerName = item.DName + "_" + item.DUniversity + "_" + item.DDepartment; } } } return(View("Delete" + pagenum, articleContent)); }
public List <T> FindOtherName <T>() where T : BaseModel { List <T> oResultS = new List <T>(); string constr = "server=.;database=CustomerDB;uid=sa;pwd=sasa"; Type type = typeof(T); var props = ""; foreach (PropertyInfo property in type.GetProperties()) { if (property.IsDefined(typeof(RemarkAttribute), true)) { RemarkAttribute remarkAttribute = (RemarkAttribute)property.GetCustomAttribute(typeof(RemarkAttribute), true); props += $"{remarkAttribute.remark} as {property.Name},"; } else { props += $"{property.Name},"; } } string sql = $"select {props.Substring(0,props.Length-1)} from [{type.Name}]"; using (SqlConnection con = new SqlConnection(constr)) { using (SqlCommand command = new SqlCommand()) { command.Connection = con; command.CommandText = sql; con.Open(); SqlDataReader reader = command.ExecuteReader(); while (reader.Read()) { object oResult = Activator.CreateInstance(type); foreach (PropertyInfo prop in type.GetProperties()) { prop.SetValue(oResult, reader[prop.Name]); } oResultS.Add(oResult as T); } } } return(oResultS as List <T>); }
/// <summary> /// 获取当前枚举值的Remark /// </summary> /// <param name="value"></param> /// <returns></returns> public static string GetRemark(this Enum value) { string remark = string.Empty; Type type = value.GetType(); FieldInfo fieldInfo = type.GetField(value.ToString()); object[] attrs = fieldInfo.GetCustomAttributes(typeof(RemarkAttribute), true); RemarkAttribute attr = (RemarkAttribute)attrs.FirstOrDefault(a => a is RemarkAttribute); if (attr == null) { remark = fieldInfo.Name; } else { remark = attr.Remark; } return(remark); }
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { DataRowView dv = e.Row.DataItem as DataRowView; Literal ltlBedStatus = e.Row.Cells[7].FindControl("ltlBedStatus") as Literal; if (Convert.ToInt32(dv[TB_Bed.col_Status]) == (int)TypeManager.BedStatus.Free) { ltlBedStatus.Text = RemarkAttribute.GetEnumRemark(TypeManager.BedStatus.Free); } else if (Convert.ToInt32(dv[TB_Bed.col_Status]) == (int)TypeManager.BedStatus.Occupy) { ltlBedStatus.Text = RemarkAttribute.GetEnumRemark(TypeManager.BedStatus.Occupy); } else if (Convert.ToInt32(dv[TB_Bed.col_Status]) == (int)TypeManager.BedStatus.Busy) { ltlBedStatus.Text = RemarkAttribute.GetEnumRemark(TypeManager.BedStatus.Busy); } } }
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { DataRowView dv = e.Row.DataItem as DataRowView; e.Row.Cells[6].Text = "<a href='javascript:void(0);' onclick='view(" + dv[TB_Bed.col_ID] + ");'>" + dv[TB_Bed.col_Name].ToString() + "</a>"; Literal ltlBedStatus = e.Row.FindControl("ltlBedStatus") as Literal; if (Convert.ToInt32(dv[TB_Bed.col_Status]) == (int)TypeManager.BedStatus.Free) { ltlBedStatus.Text = RemarkAttribute.GetEnumRemark(TypeManager.BedStatus.Free); } else if (Convert.ToInt32(dv[TB_Bed.col_Status]) == (int)TypeManager.BedStatus.Occupy) { ltlBedStatus.Text = RemarkAttribute.GetEnumRemark(TypeManager.BedStatus.Occupy); } else if (Convert.ToInt32(dv[TB_Bed.col_Status]) == (int)TypeManager.BedStatus.Busy) { ltlBedStatus.Text = RemarkAttribute.GetEnumRemark(TypeManager.BedStatus.Busy); } } }
/// <summary> /// 经典案例 /// </summary> /// <returns></returns> public ActionResult ClassCases() { // 根据不同的类型可以把title改下 string emumtext = RemarkAttribute.GetEnumRemark(AcTypeEmun.CLASSCASE); ViewBag.Title = "吉家尚" + emumtext + "列表页"; LayoutViewModel masterModel = new LayoutViewModel(db); masterModel.classicCase = db.ArticleContents .Where(w => w.ACType == AcTypeEmun.CLASSCASE.ToString().ToUpper()) .OrderBy(o => new { o.ACSortNum, o.InDateTime }) .OrderBy(o => o.ACSortNum).ToList(); masterModel.groupBuilds = db.ArticleContents .Where(w => w.ACType == AcTypeEmun.GROUPBUILD.ToString().ToUpper()) .Take(4).OrderBy(o => new { o.ACSortNum, o.InDateTime }) .OrderBy(o => o.ACSortNum).ToList(); return(View(masterModel)); }
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e) { try { if (e.Row.RowType == DataControlRowType.DataRow) { DataRowView dv = e.Row.DataItem as DataRowView; Literal ltlSex = e.Row.Cells[3].FindControl("ltlSex") as Literal; if (Convert.ToInt32(dv[TB_EmployeeCheckIn.col_Sex]) == (int)TypeManager.Sex.Male) { ltlSex.Text = RemarkAttribute.GetEnumRemark(TypeManager.Sex.Male); } else if (Convert.ToInt32(dv[TB_EmployeeCheckIn.col_Sex]) == (int)TypeManager.Sex.Female) { ltlSex.Text = RemarkAttribute.GetEnumRemark(TypeManager.Sex.Female); } } } catch (Exception ex) { LogManager.GetInstance().ErrorLog("CheckOutDefine::GridView1_RowDataBound", ex); } }
/// <summary> /// 实例对象的值 /// </summary> /// <param name="obj">初始传入的Obj对象</param> /// <param name="type">初始Obj对象的Type类型</param> /// <param name="mType">当前Obj配置的MethodType枚举类型</param> /// <param name="flag">【非必填】是否第一次(true:是 flase:否)</param> /// <param name="remark">【非必填】MethodType为值类型集合ValList时需要传入</param> /// <returns></returns> private static object GetInstance(Object obj, Type type, MethodType mType, ref Tuple <int, List <FiledsData> > tuple, bool flag = false, RemarkAttribute remark = null) { var zIndex = tuple.Item1; //值类型的枚举集合 var valTypeList = new[] { MethodType.ValList, MethodType.Val }; //值类型-不需要创建实例-直接赋值 var info = !valTypeList.Contains(mType) ? Activator.CreateInstance(type) : remark.DefaultVal; //若flag=true。表示首次进入,初始对象obj等于当前首次实例对象 if (flag) { obj = info; } //值类型-没有属性无需循环赋值 if (!valTypeList.Contains(mType)) { if (flag && remark != null) { var attrInfo = remark;//获取特性 var filedsList = tuple.Item2 ?? new List <FiledsData>(); filedsList.Add(new FiledsData() { Remark = attrInfo.Remark, //说明 IsWrite = attrInfo.Remark.Replace(" ", "").IndexOf("*") == 0 ? (int)FiledStatus.必填 : (int)FiledStatus.非必填, //是否必填 Value = "", //默认值 ZIndex = zIndex - 1, //层级 Name = remark.FiledName, //字段名 FiledType = "--", //字段类型 }); tuple = new Tuple <int, List <FiledsData> >(tuple.Item1, filedsList); } //循环值类型对象的属性值 foreach (var item in type.GetProperties()) { var attrInfo = (RemarkAttribute)item.GetCustomAttribute(typeof(RemarkAttribute)); //获取特性 var val = SetFieldsValByType(obj, item, attrInfo, ref tuple); //获取属性的真实值 item.SetValue(info, val, null); //将值给当前实例对象info var filedsList = tuple.Item2 ?? new List <FiledsData>(); if (!filedsList.Any(x => x.ZIndex == zIndex && x.Name == item.Name)) { filedsList.Add(new FiledsData() { Remark = attrInfo.Remark, //说明 IsWrite = attrInfo.Remark.Replace(" ", "").IndexOf("*") == 0 ? (int)FiledStatus.必填 : (int)FiledStatus.非必填, //是否必填 Value = "", //默认值 ZIndex = zIndex, //层级 Name = item.Name, //字段名 FiledType = ConvertUtils.GetFieldsType(item.PropertyType), //字段类型 }); } tuple = new Tuple <int, List <FiledsData> >(tuple.Item1, filedsList); } } //枚举类型为集合 if (mType == MethodType.List || mType == MethodType.ValList) { //实例一个当前type类型的集合 var generic = typeof(List <>).MakeGenericType(new Type[] { type }); //创建集合实例并转为 集合类型 var objList = Activator.CreateInstance(generic) as IList; objList.Add(info);//将设置在特性的值放入到集合 return(objList); } return(info); }
protected void btnAssign_Click(object sender, EventArgs e) { try { var sInputID = this.txtScanCardNO.Text.Trim(); var sWorkDayNO = this.txtWorkDayNo.Text.Trim(); string sIdCard = string.Empty; GetIdCardNumber(sInputID, sWorkDayNO, out sIdCard); DataTable dt = ViewState["dtSetupContent"] as DataTable; DataRow[] drArr = null; DataTable dtAssignRoom = ViewState["dtAssignedRoom"] as DataTable; DataRow[] drAssignRoomArr = null; //ServiceReference1.EmployeeInfoSoapClient employee = new ServiceReference1.EmployeeInfoSoapClient(); //DataTable dtEmployeeInfo = employee.GetEmployee(this.txtScanCardNO.Text.Trim()); //查询人员信息 DataTable dtEmployeeInfo = new StaffingBLL().GetTableWithIDL(sWorkDayNO, sIdCard); //DataTable dtEmployeeInfo = new DataTable(); //dtEmployeeInfo.Columns.Add("Segment"); //dtEmployeeInfo.Columns.Add("EmployeeID"); //dtEmployeeInfo.Columns.Add("IDCard"); //dtEmployeeInfo.Columns.Add("ChineseName"); //dtEmployeeInfo.Columns.Add("Sex"); //DataRow drNew = dtEmployeeInfo.NewRow(); //drNew["Segment"] = "BU1"; //drNew["EmployeeID"] = "2051773"; //drNew["IDCard"] = "1234567890"; //drNew["ChineseName"] = "Eric liu"; //drNew["Sex"] = "男"; //dtEmployeeInfo.Rows.Add(drNew); if (!DataTableHelper.IsEmptyDataTable(dtEmployeeInfo)) { string condition = " BU='" + dtEmployeeInfo.Rows[0]["SegmentName"] + "' and Sex ='" + dt.Rows[0]["Sex"] + "' "; drArr = dt.Select(condition); drAssignRoomArr = dtAssignRoom.Select("DormAreaID=" + drArr[0]["DormAreaID"] + " and BuildingID=" + drArr[0]["BuildingID"] + " and RoomType=" + drArr[0]["RoomType"] + " and RoomSexType='" + drArr[0]["Sex"] + "'"); string sDormAreaName = drAssignRoomArr[0]["DormAreaName"].ToString(); string sBuildingName = drAssignRoomArr[0]["BuildingName"].ToString(); string sRoomName = drAssignRoomArr[0]["RoomName"].ToString(); string sBedName = drAssignRoomArr[0]["BedName"].ToString(); if (dtEmployeeInfo.Rows[0]["Sex"].ToString() == RemarkAttribute.GetEnumRemark(TypeManager.Sex.Male)) { this.txtEmployeeNo.Text = dtEmployeeInfo.Rows[0]["EmployeeID"].ToString(); this.txtCardNo.Text = dtEmployeeInfo.Rows[0]["IDCardNumber"].ToString(); this.txtName.Text = dtEmployeeInfo.Rows[0]["ChineseName"].ToString(); this.txtBU.Text = dtEmployeeInfo.Rows[0]["SegmentName"].ToString(); this.txtDormArea.Text = drAssignRoomArr[0]["DormAreaName"].ToString(); this.txtBuilding.Text = drAssignRoomArr[0]["BuildingName"].ToString(); this.txtRoom.Text = drAssignRoomArr[0]["RoomName"].ToString(); this.txtBed.Text = drAssignRoomArr[0]["BedName"].ToString(); } else { //this.rbSex.SelectedValue = Convert.ToString((int)TypeManager.Sex.Female); this.txtFemaleEmployeeNo.Text = dtEmployeeInfo.Rows[0]["EmployeeID"].ToString(); this.txtFemaleCardNo.Text = dtEmployeeInfo.Rows[0]["IDCardNumber"].ToString(); this.txtFemaleName.Text = dtEmployeeInfo.Rows[0]["ChineseName"].ToString(); this.txtFemaleBU.Text = dtEmployeeInfo.Rows[0]["SegmentName"].ToString(); this.txtFemaleDormArea.Text = drAssignRoomArr[0]["DormAreaName"].ToString(); this.txtFemaleBuilding.Text = drAssignRoomArr[0]["BuildingName"].ToString(); this.txtFemaleRoom.Text = drAssignRoomArr[0]["RoomName"].ToString(); this.txtFemaleBed.Text = drAssignRoomArr[0]["BedName"].ToString(); } //检查是否已经有CheckIn的记录 DataTable DtCheck = new AssignRoomBLL().GetAssignedData(dtEmployeeInfo.Rows[0]["IDCardNumber"].ToString(), ""); if (DtCheck != null && DtCheck.Rows.Count > 0) { ScriptManager.RegisterClientScriptBlock(this.UpdatePanel1, this.GetType(), "msg", "alert('此用户已有分配记录!')", true); } else { TB_EmployeeCheckIn mTB_EmployeeCheckIn = new TB_EmployeeCheckIn(); mTB_EmployeeCheckIn.RoomID = Convert.ToInt32(drAssignRoomArr[0]["RoomID"]); mTB_EmployeeCheckIn.BedID = int.Parse(drAssignRoomArr[0]["BedID"].ToString()); mTB_EmployeeCheckIn.BU = Util.NormalBU(dtEmployeeInfo.Rows[0]["SegmentName"].ToString()); mTB_EmployeeCheckIn.CardNo = sIdCard; //this.txtScanCardNO.Text; mTB_EmployeeCheckIn.CheckInDate = DateTime.Now; mTB_EmployeeCheckIn.Company = string.Empty; mTB_EmployeeCheckIn.EmployeeNo = dtEmployeeInfo.Rows[0]["EmployeeID"].ToString(); mTB_EmployeeCheckIn.Name = dtEmployeeInfo.Rows[0]["ChineseName"].ToString(); mTB_EmployeeCheckIn.Sex = drAssignRoomArr[0]["RoomSexType"].ToString() == "男" ? 1 : 2; mTB_EmployeeCheckIn.SiteID = (base.UserInfo == null ? base.SystemAdminInfo.SiteID : base.UserInfo.SiteID); mTB_EmployeeCheckIn.Creator = (base.UserInfo == null ? base.SystemAdminInfo.Account : base.UserInfo.ADAccount); mTB_EmployeeCheckIn.IsActive = (int)TypeManager.IsActive.Invalid; mTB_EmployeeCheckIn.Telephone = dtEmployeeInfo.Rows[0]["Phone"].ToString(); var bAssign = new AssignRoomBLL().AssignRoom(mTB_EmployeeCheckIn); if (!bAssign) { var msg = "分配房间失败,请重新分配"; ScriptManager.RegisterClientScriptBlock(this.UpdatePanel1, this.GetType(), "msg", "alert('" + msg + "')", true); return; } dtAssignRoom.Rows.Remove(drAssignRoomArr[0]); ViewState["dtAssignedRoom"] = dtAssignRoom; //this.txtNation.Text = dt.Rows[0]["Nation"].ToString(); //this.txtAddress.Text = dt.Rows[0]["Address"].ToString(); //this.txtDept.Text = dt.Rows[0]["Segment"].ToString(); //this.txtBirthDay.Text = dt.Rows[0]["Birth"].ToString(); if (dtEmployeeInfo.Rows[0]["Phone"].ToString() != "") { string sContent = dtEmployeeInfo.Rows[0]["EmployeeID"].ToString() + "亲,以下是你被分配的宿舍信息:" + sDormAreaName + "宿舍 " + sBuildingName + "栋 " + sRoomName + "房间 " + sBedName + "床. 该宿舍的服务热线18926980019,请于3天内前往宿舍区办理入住手续,谢谢! "; try { SendSMS(dtEmployeeInfo.Rows[0]["Phone"].ToString(), sContent); } catch { return; } } } } else { ScriptManager.RegisterClientScriptBlock(this.UpdatePanel1, this.GetType(), "msg", "alert('招聘系统找不到此用户!')", true); } //this.txtScanCardNO.Text = string.Empty; //this.ReadCardTimer.Enabled = true; //this.txtScanCardNO.Focus(); } catch { ScriptManager.RegisterClientScriptBlock(this.UpdatePanel1, this.GetType(), "msg", "alert('异常错误,请检查!')", true); } finally { ClearWorkIDInput(); } }
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e) { try { if (e.Row.RowType == DataControlRowType.DataRow) { var dv = e.Row.DataItem as DataRowView; Literal ltlSex = e.Row.Cells[3].FindControl("ltlSex") as Literal; if (Convert.ToInt32(dv["Sex"]) == (int)TypeManager.Sex.Male) { ltlSex.Text = RemarkAttribute.GetEnumRemark(TypeManager.Sex.Male); } else { ltlSex.Text = RemarkAttribute.GetEnumRemark(TypeManager.Sex.Female); } int nVal = 0; Literal ltlRequireType = e.Row.Cells[8].FindControl("ltlRequireType") as Literal; int.TryParse(dv["RequireType"].ToString(), out nVal); switch (nVal) { case 1: ltlRequireType.Text = "新入住"; break; case 2: ltlRequireType.Text = "复入住"; break; case 3: ltlRequireType.Text = "调房"; break; } nVal = -1; Literal ltlHasHousingAllowance = e.Row.Cells[8].FindControl("ltlHasHousingAllowance") as Literal; int.TryParse(dv["HasHousingAllowance"].ToString(), out nVal); ltlHasHousingAllowance.Text = (nVal > 0) ? "是" : "否"; nVal = -1; Literal ltStatus = e.Row.Cells[12].FindControl("ltlStatus") as Literal; int.TryParse(dv["Status"].ToString(), out nVal); switch (nVal) { case 0: ltStatus.Text = "<span style='color:#FF9900'>等待处理</span>"; break; case 1: ltStatus.Text = "<span style='color:Blue'>批准</span>"; break; default: ltStatus.Text = "<span style='color:Red'>拒绝</span>"; break; } } } catch (Exception ex) { LogManager.GetInstance().ErrorLog("ApplyDorm::GridView1_RowDataBound", ex); } }
/// <summary> /// 批量导入 /// </summary> /// <param name="dt"></param> public int Import(DataTable dt, ref string errorMsg) { int site = SessionHelper.Get(HttpContext.Current, TypeManager.User) != null ? ((TB_User)SessionHelper.Get(HttpContext.Current, TypeManager.User)).SiteID : ((TB_SystemAdmin)SessionHelper.Get(HttpContext.Current, TypeManager.Admin)).SiteID; string user = SessionHelper.Get(HttpContext.Current, TypeManager.User) != null ? ((TB_User)SessionHelper.Get(HttpContext.Current, TypeManager.User)).ADAccount : ((TB_SystemAdmin)SessionHelper.Get(HttpContext.Current, TypeManager.Admin)).Account; CommonManager mCommonManager = new CommonManager(); try { #region 宿舍区 DataTable dtTB_DormArea = _mTB_DormAreaDAL.GetTableBySite(site); DataTable dtTB_DormAreaInsert = dtTB_DormArea.Clone(); DataRow[] drTB_DormAreaArr = null; var queryDormArea = from v in dt.AsEnumerable() select new { DormAreaName = v.Field <string>("宿舍区") }; foreach (var item in queryDormArea.ToList().Distinct()) { drTB_DormAreaArr = dtTB_DormArea.Select("name='" + item.DormAreaName + "'"); if (drTB_DormAreaArr.Length <= 0) { DataRow drDormAreaInsert = dtTB_DormAreaInsert.NewRow(); drDormAreaInsert["Name"] = item.DormAreaName; drDormAreaInsert["SiteID"] = site; drDormAreaInsert["Creator"] = user; dtTB_DormAreaInsert.Rows.Add(drDormAreaInsert); } } dtTB_DormAreaInsert.Columns.Remove("ID"); if (dtTB_DormAreaInsert.Rows.Count > 0) { mCommonManager.DTToDB(dtTB_DormAreaInsert, "TB_DormArea", new string[] { "SiteID", "Name", "Creator" }, DBO.GetInstance().CreateConnection().ConnectionString); } #endregion #region 楼栋 dtTB_DormArea = _mTB_DormAreaDAL.GetTableBySite(site); DataTable dtTB_Building = _mTB_BuildingDAL.GetTableBySiteID(site); DataTable dtTB_BuildingInsert = dtTB_Building.Clone(); DataRow[] drTB_BuildingArr = null; var queryBuilding = from v in dt.AsEnumerable() select new { DormAreaName = v.Field <string>("宿舍区"), BuildingName = v.Field <string>("楼栋"), }; foreach (var item in queryBuilding.ToList().Distinct()) { drTB_BuildingArr = dtTB_Building.Select("Name='" + item.BuildingName + "' and DormAreaName='" + item.DormAreaName + "'"); if (drTB_BuildingArr.Length <= 0) { drTB_DormAreaArr = dtTB_DormArea.Select("Name='" + item.DormAreaName + "'"); DataRow drTB_BuildingInsert = dtTB_BuildingInsert.NewRow(); drTB_BuildingInsert["DormAreaID"] = drTB_DormAreaArr[0]["ID"]; drTB_BuildingInsert["Name"] = item.BuildingName; drTB_BuildingInsert["SiteID"] = site; drTB_BuildingInsert["Creator"] = user; dtTB_BuildingInsert.Rows.Add(drTB_BuildingInsert); } } dtTB_BuildingInsert.Columns.Remove("ID"); dtTB_BuildingInsert.Columns.Remove("DormAreaName"); if (dtTB_BuildingInsert.Rows.Count > 0) { mCommonManager.DTToDB(dtTB_BuildingInsert, "TB_Building", new string[] { "DormAreaID", "Name", "Creator", "SiteID" }, DBO.GetInstance().CreateConnection().ConnectionString); } #endregion #region 房间 dtTB_DormArea = _mTB_DormAreaDAL.GetTableBySite(site); dtTB_Building = _mTB_BuildingDAL.GetTableBySiteID(site); DataTable dtTB_RoomType = _mTB_RoomTypeDAL.GetTable(site); DataTable dtTB_Room = _mTB_RoomDAL.GetTableBySiteID(site); DataTable dtTB_RoomInsert = dtTB_Room.Clone(); DataRow[] drTB_RoomArr = null; DataTable dtRoomType = new TB_RoomTypeDAL().GetTable(site); var queryRoom = from v in dt.AsEnumerable() select new { DormAreaName = v.Field <string>("宿舍区"), BuildingName = v.Field <string>("楼栋"), RoomName = v.Field <string>("房间号"), RoomType = v.Field <string>("房间类型"), RoomSexType = v.Field <string>("性别"), }; foreach (var item in queryRoom.ToList().Distinct()) { DataRow[] dr = dtTB_RoomType.Select("Name='" + item.RoomType + "'"); if (dr.Length == 0) { errorMsg = "房间类型:" + item.RoomType + " 不存在,请检查后再导入"; return(0); } drTB_RoomArr = dtTB_Room.Select("BuildingName='" + item.BuildingName + "' and DormAreaName='" + item.DormAreaName + "' and Name='" + item.RoomName + "'"); if (drTB_RoomArr.Length <= 0) { drTB_DormAreaArr = dtTB_DormArea.Select("Name='" + item.DormAreaName + "'"); drTB_BuildingArr = dtTB_Building.Select("Name='" + item.BuildingName + "' and DormAreaName='" + item.DormAreaName + "'"); DataRow drTB_RoomInsert = dtTB_RoomInsert.NewRow(); drTB_RoomInsert["DormAreaID"] = drTB_DormAreaArr[0]["ID"]; drTB_RoomInsert["BuildingID"] = drTB_BuildingArr[0]["ID"]; drTB_RoomInsert["Name"] = item.RoomName; drTB_RoomInsert["SiteID"] = site; drTB_RoomInsert["Creator"] = user; drTB_RoomInsert["RoomSexType"] = item.RoomSexType; drTB_RoomInsert["RoomType2"] = 0; drTB_RoomInsert["KeyCount"] = ""; DataRow[] drRoomTypeArr = dtRoomType.Select("Name='" + item.RoomType + "'"); if (drRoomTypeArr.Length > 0) { drTB_RoomInsert["RoomType"] = drRoomTypeArr[0]["ID"]; } dtTB_RoomInsert.Rows.Add(drTB_RoomInsert); } } dtTB_RoomInsert.Columns.Remove("ID"); dtTB_RoomInsert.Columns.Remove("DormAreaName"); dtTB_RoomInsert.Columns.Remove("BuildingName"); if (dtTB_RoomInsert.Rows.Count > 0) { mCommonManager.DTToDB(dtTB_RoomInsert, "TB_Room", new string[] { "Name", "RoomSexType", "RoomType" , "RoomType2", "Creator", "SiteID", "DormAreaID", "BuildingID", "KeyCount" }, DBO.GetInstance().CreateConnection().ConnectionString); } #endregion #region 床位号 dtTB_DormArea = _mTB_DormAreaDAL.GetTableBySite(site); dtTB_Building = _mTB_BuildingDAL.GetTableBySiteID(site); dtTB_Room = _mTB_RoomDAL.GetTableBySiteID(site); DataTable dtTB_Bed = _mTB_BedDAL.GetTableBySite(site); DataTable dtTB_BedInsert = dtTB_Bed.Clone(); DataRow[] drTB_BedArr = null; var queryBed = from v in dt.AsEnumerable() select new { DormAreaName = v.Field <string>("宿舍区"), BuildingName = v.Field <string>("楼栋"), RoomName = v.Field <string>("房间号"), BedName = v.Field <string>("床位号"), BedStatus = v.Field <string>("床位状态"), KeyCount = v.Field <string>("钥匙数量"), }; int iInsertCount = 0; foreach (var item in queryBed.ToList().Distinct()) { if (string.IsNullOrEmpty(item.BedName)) { errorMsg = item.DormAreaName + item.BuildingName + item.RoomName + " 存在空床位,请检查后再导入"; return(0); } drTB_BedArr = dtTB_Bed.Select("BuildingName='" + item.BuildingName + "' and DormAreaName='" + item.DormAreaName + "' and RoomName='" + item.RoomName + "' and Name='" + item.BedName + "'"); if (drTB_BedArr.Length <= 0) { drTB_DormAreaArr = dtTB_DormArea.Select("Name='" + item.DormAreaName + "'"); drTB_BuildingArr = dtTB_Building.Select("Name='" + item.BuildingName + "' and DormAreaName='" + item.DormAreaName + "'"); drTB_RoomArr = dtTB_Room.Select("Name='" + item.RoomName + "' and BuildingName='" + item.BuildingName + "' and DormAreaName='" + item.DormAreaName + "'"); DataRow drTB_BedInsert = dtTB_BedInsert.NewRow(); drTB_BedInsert["DormAreaID"] = drTB_DormAreaArr[0]["ID"]; drTB_BedInsert["BuildingID"] = drTB_BuildingArr[0]["ID"]; drTB_BedInsert["RoomID"] = drTB_RoomArr[0]["ID"]; drTB_BedInsert["Name"] = item.BedName; drTB_BedInsert["SiteID"] = site; drTB_BedInsert["Creator"] = user; drTB_BedInsert["KeyCount"] = item.KeyCount; if (item.BedStatus == RemarkAttribute.GetEnumRemark(TypeManager.BedStatus.Busy)) { drTB_BedInsert["Status"] = (int)TypeManager.BedStatus.Busy; } else if (item.BedStatus == RemarkAttribute.GetEnumRemark(TypeManager.BedStatus.Free)) { drTB_BedInsert["Status"] = (int)TypeManager.BedStatus.Free; } else if (item.BedStatus == RemarkAttribute.GetEnumRemark(TypeManager.BedStatus.Occupy)) { drTB_BedInsert["Status"] = (int)TypeManager.BedStatus.Occupy; } dtTB_BedInsert.Rows.Add(drTB_BedInsert); iInsertCount++; } } dtTB_BedInsert.Columns.Remove("ID"); dtTB_BedInsert.Columns.Remove("DormAreaName"); dtTB_BedInsert.Columns.Remove("BuildingName"); dtTB_BedInsert.Columns.Remove("RoomName"); if (dtTB_BedInsert.Rows.Count > 0) { mCommonManager.DTToDB(dtTB_BedInsert, "TB_Bed", new string[] { "Name", "Creator", "SiteID", "DormAreaID" , "BuildingID", "RoomID", "Status", "KeyCount" }, DBO.GetInstance().CreateConnection().ConnectionString); } return(iInsertCount); #endregion } catch (Exception ex) { throw ex; } }
// GET: ArticleContents/Edit/5 public ActionResult Edit() { string idnum = Request.QueryString["id"]; int id = 0; if (idnum == null || !Int32.TryParse(idnum, out id)) { return(View("error")); } if (id.Equals("0")) { return(View("error")); } ArticleContent articleContent = db.ArticleContents.Find(id); if (articleContent == null) { return(HttpNotFound()); } string typestr = Request.QueryString["type"]; int type = 0; if (typestr == null || !Int32.TryParse(typestr, out type) || !Enum.IsDefined(typeof(AcTypeEmun), type)) { return(View("error")); } ViewBag.TypeText = RemarkAttribute.GetEnumRemark((AcTypeEmun)type); ViewBag.TypeNum = type; ViewBag.TypeEmnu = (AcTypeEmun)type; string pagenum = "_"; if (type == (int)AcTypeEmun.GROUPBUILD || type == (int)AcTypeEmun.HOMEDESIGN || type == (int)AcTypeEmun.ENVIRONMENTAL) { pagenum += "4"; } else { pagenum += type.ToString(); } int designerListCount = 0; List <SelectListItem> designerList = new List <SelectListItem>(); if (type == (int)AcTypeEmun.CLASSCASE) { foreach (var item in db.Designers) { SelectListItem selectList = new SelectListItem(); if (articleContent.DId == item.Id) { selectList = new SelectListItem() { Text = item.DName + "_" + item.DUniversity + "_" + item.DDepartment, Value = item.Id.ToString(), Selected = true }; } else { selectList = new SelectListItem() { Text = item.DName + "_" + item.DUniversity + "_" + item.DDepartment, Value = item.Id.ToString() }; } designerList.Add(selectList); } designerListCount = db.Designers.Count(); } ViewData["DesignerList"] = designerList; ViewBag.DesignerListCount = designerListCount; return(View("Edit" + pagenum, articleContent)); }
private static object SetFieldsValByType(Object obj, PropertyInfo proccessInfo, RemarkAttribute remark, ref Tuple <int, List <FiledsData> > tuple) { //当前属性的 Type类型 var t = proccessInfo.PropertyType; if (t == typeof(string)) { return(remark.DefaultVal.ToStr()); } else if (t == typeof(Int16) || t == typeof(Int32) || t == typeof(Int64)) { return(remark.DefaultVal.ToInt(-1)); } else if (t == typeof(decimal)) { return(remark.DefaultVal.ToDecimal()); } else if (t == typeof(Double) || t == typeof(double)) { return(remark.DefaultVal.ToDouble()); } else if (t == typeof(float)) { return(remark.DefaultVal.ToFloat()); } else if (t == typeof(bool) || t == typeof(Boolean)) { return(remark.DefaultVal.ToBool()); } else if (t == typeof(DateTime)) { return(remark.DefaultVal.ToDateTime()); } else if (!t.IsValueType) { remark.FiledName = proccessInfo.Name; var zIndex = tuple.Item1 + 1; //若类型不是值类型时-根据配置的类型枚举来实例子属性对象 if (remark.MethodType == MethodType.Class) { tuple = new Tuple <int, List <FiledsData> >(zIndex, tuple.Item2); return(GetInstance(obj, proccessInfo.PropertyType, remark.MethodType, ref tuple, true, remark)); } else if (remark.MethodType == MethodType.List) { tuple = new Tuple <int, List <FiledsData> >(zIndex, tuple.Item2); //proccessInfo.PropertyType.GetGenericArguments()[0]获引用类型中包含的对象类型列表,[0]表示第一个类型,例:List<string> 获取到String 类型 List<Student>获取到Student return(GetInstance(obj, proccessInfo.PropertyType.GetGenericArguments()[0], remark.MethodType, ref tuple, true, remark)); } else if (remark.MethodType == MethodType.ValList) { tuple = new Tuple <int, List <FiledsData> >(zIndex, tuple.Item2); //proccessInfo.PropertyType.GetGenericArguments()[0]获引用类型中包含的对象类型列表,[0]表示第一个类型,例:List<string> 获取到String 类型 List<Student>获取到Student //值类型的列表-将特性Remark对象传入 return(GetInstance(obj, proccessInfo.PropertyType.GetGenericArguments()[0], remark.MethodType, ref tuple, false, remark)); } else { //其他未配置类型-直接创建实例-返回结果例如:Dictionary<object,object> 等 return(Activator.CreateInstance(proccessInfo.PropertyType)); } } else { return(""); } }
/// <summary> /// 导入 /// </summary> /// <param name="filePath"></param> /// <returns>导入失败记录</returns> public DataTable Import(string filePath) { //读取Excel内容 DataTable dt = _mExcelHelper.GetDataFromExcel(filePath); dt.Columns.Add("BZ"); DataTable dtBU = new DataTable(); //SiteID int intSiteID = SessionHelper.Get(HttpContext.Current, TypeManager.User) != null ? ((TB_User)SessionHelper.Get(HttpContext.Current, TypeManager.User)).SiteID : ((TB_SystemAdmin)SessionHelper.Get(HttpContext.Current, TypeManager.Admin)).SiteID; //操作用户账号 string currentUser = SessionHelper.Get(HttpContext.Current, TypeManager.User) != null ? ((TB_User)SessionHelper.Get(HttpContext.Current, TypeManager.User)).ADAccount : ((TB_SystemAdmin)SessionHelper.Get(HttpContext.Current, TypeManager.Admin)).Account; DataTable dtTB_EmployeeCheckInInsert = new DataTable();//入住人员信息 dtTB_EmployeeCheckInInsert.Columns.Add("RoomID"); dtTB_EmployeeCheckInInsert.Columns.Add("BedID"); dtTB_EmployeeCheckInInsert.Columns.Add("EmployeeNo"); dtTB_EmployeeCheckInInsert.Columns.Add("Sex"); dtTB_EmployeeCheckInInsert.Columns.Add("BUID"); dtTB_EmployeeCheckInInsert.Columns.Add("BU"); dtTB_EmployeeCheckInInsert.Columns.Add("Company"); dtTB_EmployeeCheckInInsert.Columns.Add("CardNo"); dtTB_EmployeeCheckInInsert.Columns.Add("CheckInDate"); dtTB_EmployeeCheckInInsert.Columns.Add("Creator"); dtTB_EmployeeCheckInInsert.Columns.Add("SiteID"); dtTB_EmployeeCheckInInsert.Columns.Add("Name"); dtTB_EmployeeCheckInInsert.Columns.Add("IsActive"); dtTB_EmployeeCheckInInsert.Columns.Add("Telephone"); dtTB_EmployeeCheckInInsert.Columns.Add("EmployeeTypeName"); //获取到整个site的所有入住人员信息 DataTable dtEmployeeCheckIn = _mTB_EmployeeCheckInDAL.GetTableBySiteID(intSiteID); //获取到整个site的所有未入住床位信息 DataTable dtTB_Bed = _mTB_BedDAL.GetTableBySiteCheckIn(intSiteID); DataTable dtError = dt.Clone(); StringBuilder sbBedID = new StringBuilder();//用于保存床位ID #region int buID = 0; #endregion foreach (DataRow dr in dt.Rows) { try { dtBU = _mTB_BUDAL.Get(intSiteID, dr[TypeManager.Col_BU].ToString());//.Rows.Count buID = dtBU.Rows.Count > 0 ? Convert.ToInt32(dtBU.Rows[0][0]) : 0; DataRow[] drEmployeeCheckInArr = dtEmployeeCheckIn.Select("CardNo='" + dr["身份证号码"] + "'"); DataRow[] drEmployeeCheckEmployeeNo = dtEmployeeCheckIn.Select("EmployeeNo='" + dr["工号"] + "'"); if (drEmployeeCheckInArr.Length > 0) { UpdateExistCheckin(dtError, dr, drEmployeeCheckInArr); } else if (drEmployeeCheckEmployeeNo.Length > 0) { UpdateExistCheckin(dtError, dr, drEmployeeCheckEmployeeNo); } else { DataRow[] drTB_BedArr = dtTB_Bed.Select("DormAreaName='" + dr["宿舍区"] + "' and BuildingName='" + dr["楼栋"] + "' and RoomName='" + dr["房间号"] + "' and Name='" + dr["床位号"] + "'"); if (drTB_BedArr.Length > 0) { if (drTB_BedArr[0]["IsEnable"] != null) { if (drTB_BedArr[0]["IsEnable"].ToString() == "已禁用") { dr["BZ"] = "床位信息错误:已禁用"; dtError.ImportRow(dr); continue; } } DataRow drTB_EmployeeCheckInInsert = dtTB_EmployeeCheckInInsert.NewRow(); drTB_EmployeeCheckInInsert["BedID"] = Convert.ToInt32(drTB_BedArr[0]["ID"]); drTB_EmployeeCheckInInsert["RoomID"] = Convert.ToInt32(drTB_BedArr[0]["RoomID"]); drTB_EmployeeCheckInInsert["SiteID"] = intSiteID; drTB_EmployeeCheckInInsert["CardNo"] = dr[TypeManager.Col_CardNo].ToString(); drTB_EmployeeCheckInInsert["BUID"] = buID; drTB_EmployeeCheckInInsert["BU"] = dr[TypeManager.Col_BU].ToString(); drTB_EmployeeCheckInInsert["CheckInDate"] = Convert.ToDateTime(dr[TypeManager.Col_CheckInDate]); drTB_EmployeeCheckInInsert["Company"] = dr[TypeManager.Col_Company].ToString(); drTB_EmployeeCheckInInsert["Creator"] = currentUser; drTB_EmployeeCheckInInsert["IsActive"] = (int)TypeManager.IsActive.Valid; drTB_EmployeeCheckInInsert["EmployeeNo"] = dr[TypeManager.Col_EmployeeNo].ToString(); drTB_EmployeeCheckInInsert["Name"] = dr[TypeManager.Col_Name].ToString(); drTB_EmployeeCheckInInsert["Sex"] = RemarkAttribute.GetEnumRemark(TypeManager.Sex.Male) == dr[TypeManager.Col_Sex].ToString() ? (int)TypeManager.Sex.Male : (int)TypeManager.Sex.Female; drTB_EmployeeCheckInInsert["Telephone"] = dr["手机号码"]; drTB_EmployeeCheckInInsert["EmployeeTypeName"] = dr["用工类型"]; dtTB_EmployeeCheckInInsert.Rows.Add(drTB_EmployeeCheckInInsert); sbBedID.Append(drTB_BedArr[0]["ID"] + ","); } else { dr["BZ"] = "床位信息错误:已有入住信息或不存在"; dtError.ImportRow(dr); } } } catch (Exception ex) { dr["BZ"] = ex.Message; dtError.ImportRow(dr); } } if (dtTB_EmployeeCheckInInsert.Rows.Count > 0) { //添加入住记录 new CommonManager().DTToDB(dtTB_EmployeeCheckInInsert, "TB_EmployeeCheckIn" , new string[] { "RoomID", "BedID", "EmployeeNo", "Sex", "BUID", "BU", "Company", "CardNo", "CheckInDate", "Creator", "SiteID", "Name", "IsActive", "Telephone", "EmployeeTypeName" } , DBO.GetInstance().CreateConnection().ConnectionString); //更新床位状态 _mTB_BedDAL.Update(sbBedID.ToString().TrimEnd(','), TypeManager.BedStatus.Busy); } return(dtError); }