Ejemplo n.º 1
0
        public ActionResult StaffJobDetail(string staffid)
        {
            try
            {
                V_HR_StaffJobWithName sj = (from o in entities.V_HR_StaffJobWithName
                                            where o.StaffID == staffid
                                            select o).First();
                var textstaffid = X.GetCmp <TextField>("StaffID");
                textstaffid.Text = sj.StaffID;
                //var textdep = X.GetCmp<TextField>("SDepartMentName");
                //textdep.Text = sj.SDepartMentName;
                var textstafftype = X.GetCmp <TextField>("StaffType");
                textstafftype.Text = sj.StaffType;
                var textname = X.GetCmp <TextField>("Name");
                textname.Text = sj.Name;
                var textentrytime = X.GetCmp <TextField>("EntryTime");
                textentrytime.Text = Convert.ToDateTime(sj.EntryTime.ToString()).ToString("yyyy-MM-dd");

                var list = (from o in entities.V_HR_StaffJobWithName
                            where o.StaffID == staffid
                            select o).ToList();
                return(View(list));
            }
            catch (Exception e)
            {
                X.Msg.Alert("警告", "数据库查询失败!<br /> note:" + e.Message).Show();
                return(this.Direct());
            }
        }
Ejemplo n.º 2
0
        public ActionResult AddStaffJob(string staffJobid) //在修改时传递的为contractid
        {
            if (staffJobid == "-1")                        //-1为添加
            {
                //var s = X.GetCmp<TextField>("StaffID");
                //s.Text = "qwerqwreq";
                return(View());
            }
            else//否则为修改
            {
                V_HR_StaffJobWithName item = (from o in entities.V_HR_StaffJobWithName
                                              where o.StaffJobID == staffJobid
                                              select o).First();

                return(View(item));
            }
        }
Ejemplo n.º 3
0
        public ActionResult AddOrEditStaffJob(V_HR_StaffJobWithName staffJob)//AddstaffJob保存相应
        {
            DirectResult  r = new DirectResult();
            T_HR_StaffJob staffJobupdate = entities.T_HR_StaffJob.Find(staffJob.StaffJobID);

            if (staffJobupdate == null)//为空为添加
            {
                T_HR_StaffJob staffJobadd = new T_HR_StaffJob();
                staffJobadd.StaffJobID = Tool.ProduceSed64();
                staffJobadd.StaffID    = staffJob.StaffID;
                staffJobadd.JobID      = staffJob.JobID;
                if (staffJob.ValidTime <= DateTime.Now.Date)//添加保存时可能存在两个有效职位,但是没有用到添加,员工职位的添加是在入职时设置的,那时还不存在该员工职位记录
                {
                    staffJobadd.IsValid = true;
                }
                else
                {
                    staffJobadd.IsValid = false;
                }
                staffJobadd.ValidTime   = staffJob.ValidTime;
                staffJobadd.Remark      = staffJob.Remark;
                staffJobadd.CreaterName = "admin";//后期改为用户名
                staffJobadd.CreateTime  = DateTime.Now;
                entities.T_HR_StaffJob.Add(staffJobadd);
                try
                {
                    entities.SaveChanges();
                    r.Success = true;
                    X.Msg.Alert("提示", "保存成功!", new JFunction {
                        Fn = "closewindow"
                    }).Show();
                }
                catch (Exception e)
                {
                    X.Msg.Alert("警告", "数据保存失败!<br /> note:" + e.Message, new JFunction {
                        Fn = "closewindow"
                    }).Show();
                    r.Success = false;
                }
            }
            else//否则为修改
            {
                T_HR_Staff s = entities.T_HR_Staff.Find(staffJob.StaffID);
                s.StaffType = staffJob.StaffType;
                T_HR_StaffJob staffJobadd = new T_HR_StaffJob();
                staffJobadd.StaffJobID = Tool.ProduceSed64();
                staffJobadd.StaffID    = staffJob.StaffID;
                staffJobadd.JobID      = staffJob.JobID;
                if (staffJob.ValidTime <= DateTime.Now.Date)
                {
                    staffJobupdate.IsValid = false;
                    staffJobadd.IsValid    = true;
                }
                else
                {
                    staffJobupdate.IsValid = true;
                    staffJobadd.IsValid    = false;
                }
                staffJobadd.ValidTime   = staffJob.ValidTime;
                staffJobadd.ChangeType  = staffJob.ChangeType;
                staffJobadd.Remark      = staffJob.Remark;
                staffJobadd.CreaterName = "admin";//后期改为用户名
                staffJobadd.CreateTime  = DateTime.Now;
                entities.T_HR_StaffJob.Add(staffJobadd);
                try
                {
                    entities.SaveChanges();
                    r.Success = true;
                    X.Msg.Alert("提示", "保存成功!", new JFunction {
                        Fn = "closewindow"
                    }).Show();
                }
                catch (Exception e)
                {
                    X.Msg.Alert("警告", "数据保存失败!<br /> note:" + e.Message, new JFunction {
                        Fn = "closewindow"
                    }).Show();
                    r.Success = false;
                }
            }
            return(r);
        }