Example #1
0
        public ActionResult JSDeleteContract(SubmitHandler handler)//删除响应
        {
            var    s = X.GetCmp <Store>("ContractStore");
            string id;

            Dictionary <string, string>[] values = JSON.Deserialize <Dictionary <string, string>[]>(handler.Json.ToString());

            if (values.Length > 0)//js代码已经处理过,此处判断无用,可删
            {
                foreach (Dictionary <string, string> row in values)
                {
                    id = row["ID"];
                    T_HR_Contract de = entities.T_HR_Contract.Find(id);
                    if (de != null)
                    {
                        //entities.T_HR_Contract.Remove(de);
                        de.Valid = false;
                        try
                        {
                            entities.SaveChanges();
                            s.Remove(id);
                        }
                        catch (Exception e)
                        {
                            X.Msg.Alert("警告", "数据删除失败!<br /> note:" + e.Message).Show();
                        }
                    }
                }
            }
            else
            {
                X.Msg.Alert("提示", "未选择任何列!").Show();
            }

            return(this.Direct());
        }
Example #2
0
        public ActionResult AddOrEditContract(V_HR_ContractWithStaffName contract)//AddContract保存相应
        {
            T_HR_Contract contractupdate = entities.T_HR_Contract.Find(contract.ID);

            DirectResult r = new DirectResult();

            if (contractupdate == null)//为空为添加
            {
                var ca = (from o in entities.V_HR_ContractWithStaffName
                          where o.StaffID == contract.StaffID && o.Valid == true
                          select o).ToList();
                if (!ca.Any())
                {
                    T_HR_Contract contractadd = new T_HR_Contract();
                    contractadd.ID           = Tool.ProduceSed64();
                    contractadd.StaffID      = contract.StaffID;
                    contractadd.Num          = contract.Num;
                    contractadd.ContractType = contract.ContractType;
                    contractadd.StartTime    = contract.StartTime;
                    contractadd.EndTime      = contract.EndTime;
                    contractadd.Years        = contract.Years;
                    contractadd.Company      = contract.Company;
                    contractadd.Valid        = true;
                    contractadd.Remark       = contract.Remark;
                    contractadd.CreaterName  = new LoginUser().EmployeeId;//后期改为用户名
                    contractadd.CreateTime   = DateTime.Now;
                    entities.T_HR_Contract.Add(contractadd);
                    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
                {
                    X.Msg.Alert("警告", "该员工合同已存在,不可重复添加!").Show();
                    return(this.Direct());
                }
            }
            else//否则为修改
            {
                //contractupdate.StaffID = contract.StaffID;
                contractupdate.Num          = contract.Num;
                contractupdate.ContractType = contract.ContractType;
                contractupdate.StartTime    = contract.StartTime;
                contractupdate.EndTime      = contract.EndTime;
                contractupdate.Years        = contract.Years;
                contractupdate.Company      = contract.Company;
                contractupdate.Valid        = true;
                contractupdate.Remark       = contract.Remark;
                contractupdate.EditorName   = new LoginUser().EmployeeId;//后期改为用户名
                contractupdate.EditeTime    = DateTime.Now;
                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);
        }