Esempio n. 1
0
        /// <summary>
        /// 重新加载这个人的常用原因
        /// </summary>
        /// <param name="Userid">用户id</param>
        /// <returns></returns>
        public ActionResult ReloadBonusReson(string Userid, string companyId)
        {
            string            str            = string.Format("select * from BonusReson where BonusResonUserId='{0}' and companyId='{1}'", Base64MIMA.JIE(Userid), Base64MIMA.JIE(companyId));
            DataTable         dt             = sql.GetDataTableCommand(str);
            List <BonusReson> BonusResonList = new List <BonusReson>();

            if (dt.Rows.Count > 0)
            {
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    BonusReson br = new BonusReson();
                    br.ID               = long.Parse(dt.Rows[i]["ID"].ToString());
                    br.BonusResonName   = dt.Rows[i]["BonusResonName"].ToString();
                    br.BonusResonUserId = dt.Rows[i]["BonusResonUserId"].ToString();
                    BonusResonList.Add(br);
                }
                ViewBag.BonusResonList = BonusResonList;
            }
            else
            {
                ViewBag.BonusResonList = null;
            }
            return(PartialView("_PartialReBonus"));
        }
Esempio n. 2
0
        // GET: SendBonus
        public ActionResult Index(string spCodesTemp, string userID, string counts, string companyId)
        {
            ViewBag.companyId = companyId;

            InitJsapi(companyId);
            companyId      = Base64MIMA.JIE(companyId);
            ViewBag.counts = int.Parse(Base64MIMA.JIE(counts));
            ViewBag.count  = counts;//加密的
            string userid = Base64MIMA.JIE(userID);

            ViewBag.userid = userID;
            string sqlstr = string.Format("exec proc_BonusOutput 'SelectItem','{0}','{1}'", userid, companyId);

            DataSet           ds             = sql.GetDataSetCommand(sqlstr);
            List <BonusItems> BonusItemsList = new List <BonusItems>();

            if (ds?.Tables.Count > 0)
            {
                #region 奖金项

                if (ds?.Tables[0].Rows.Count > 0)
                {
                    for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                    {
                        BonusItems bi = new BonusItems();
                        bi.BonusItemsId = ds.Tables[0].Rows[i]["BonusItemID"].ToString();
                        bi.BonusName    = ds.Tables[0].Rows[i]["BIName"].ToString();
                        bi.BonusMoney   = double.Parse(ds.Tables[0].Rows[i]["sumRemainMoney"].ToString());
                        bi.BonusType    = 1;//奖金项的
                        BonusItemsList.Add(bi);
                    }
                }
                if (ds?.Tables[1].Rows.Count > 0)
                {
                    for (int i = 0; i < ds.Tables[1].Rows.Count; i++)
                    {
                        BonusItems bi = new BonusItems();
                        bi.BonusItemsId = ds.Tables[1].Rows[i]["BonusItemID"].ToString();
                        bi.BonusName    = ds.Tables[1].Rows[i]["BIName"].ToString();
                        bi.BonusMoney   = double.Parse(ds.Tables[1].Rows[i]["sumRemainMoney"].ToString());
                        bi.BonusType    = 2;//授权的
                        BonusItemsList.Add(bi);
                    }
                }
                //得到授权的奖金项

                if (BonusItemsList.Where(b => b.BonusType == 2).Count() > 0)
                {
                    //判断授权的可用余额是否大于这个奖金项的余额
                    foreach (var item in BonusItemsList.Where(b => b.BonusType == 2))
                    {
                        string    ss    = string.Format(@"select ISNULL(SUM(RemainMoney),0) re from RuleData 
where BonusItemID='{0}'
and EndDate>GETDATE()", item.BonusItemsId);
                        DataTable dt_ss = sql.GetDataTableCommand(ss);
                        if (dt_ss.Rows.Count > 0)
                        {
                            if (double.Parse(dt_ss.Rows[0]["re"].ToString()) < item.BonusMoney)
                            {
                                item.BonusMoney = double.Parse(dt_ss.Rows[0]["re"].ToString());
                            }
                        }
                    }
                }


                ViewBag.BonusItemsList = BonusItemsList;
                #endregion

                #region 奖金金额
                List <BonusParameter> BonusParamList = new List <BonusParameter>();
                if (ds?.Tables[2].Rows.Count > 0)
                {
                    for (int i = 0; i < ds.Tables[2].Rows.Count; i++)
                    {
                        BonusParameter bp = new BonusParameter();
                        bp.BonusSetID = int.Parse(ds.Tables[2].Rows[i]["BonusSetID"].ToString());
                        bp.TypeName   = ds.Tables[2].Rows[i]["TypeName"].ToString();
                        bp.BonusNum   = int.Parse(ds.Tables[2].Rows[i]["BonusNum"].ToString());
                        BonusParamList.Add(bp);
                    }
                    ViewBag.BonusParamList = BonusParamList;
                }
                else
                {
                    ViewBag.BonusParamList = null;
                }
                #endregion

                #region 常用原因
                List <BonusReson> BonusResonList = new List <BonusReson>();
                if (ds.Tables[3].Rows.Count > 0)
                {
                    for (int i = 0; i < ds.Tables[3].Rows.Count; i++)
                    {
                        BonusReson br = new BonusReson();
                        br.ID               = long.Parse(ds.Tables[3].Rows[i]["ID"].ToString());
                        br.BonusResonName   = ds.Tables[3].Rows[i]["BonusResonName"].ToString();
                        br.BonusResonUserId = ds.Tables[3].Rows[i]["BonusResonUserId"].ToString();
                        BonusResonList.Add(br);
                    }
                    ViewBag.BonusResonList = BonusResonList;
                }
                else
                {
                    ViewBag.BonusResonList = null;
                }
                #endregion
            }
            //通过userid得到公司id
            //string sqlstr222 = string.Format($"select CompanyID from Employee where EmpID='{userid}'");
            //DataTable dt222 = sql.GetDataTableCommand(sqlstr222);
            //if (dt222.Rows.Count > 0)
            //{
            //    ViewBag.companyId = Base64MIMA.JIA(dt222.Rows[0]["CompanyID"].ToString());
            //}
            //else
            //{
            //    //公司注册页面
            //    return Redirect("/CompanyRegist/Index?UserID=" + userid);
            //    //return Content("<script>alert('出现错误,请联系相关人员处理');history.go(-1);</script>");
            //}
            //companyId = dt222.Rows[0]["CompanyID"].ToString();
            //ViewBag.companyId = CompanyId;

            #region 得到本公司的部门和人员(不包括已离职的和本人)
            string  sqlstr2 = string.Format($"exec proc_BonusOutput 'SelectUsers','{userid}',{companyId}");
            DataSet ds2     = sql.GetDataSetCommand(sqlstr2);
            if (ds2?.Tables.Count > 0)
            {
                #region 部门

                if (ds2?.Tables[0].Rows.Count > 0)
                {
                    ViewBag.depList = ds2.Tables[0];
                }
                else
                {
                    ViewBag.depList = null;
                }

                #endregion

                #region 人员
                if (ds2?.Tables[1].Rows.Count > 0)
                {
                    ViewBag.empList = ds2.Tables[1];
                }
                else
                {
                    ViewBag.empList = null;
                }
                #endregion
            }
            #endregion
            if (spCodesTemp == "" || spCodesTemp == null)
            {
                ViewBag.us = "";
            }
            else
            {
                ViewBag.us = Base64MIMA.JIE(spCodesTemp);
            }

            #region 人员
            ////判断是公司级还是部门级
            //string BonusItemID = "";
            //if (BonusItemsList.Count > 0)
            //{
            //    BonusItemID = BonusItemsList[0].BonusItemsId;
            //}
            //else
            //{
            //    BonusItemID = "00000000-0000-0000-0000-000000000000";
            //}
            ////string selectComOrDep = string.Format($"select * from BonusItem where BonusItemID='{BonusItemsList[0]}'");

            //string sqlstr22 = string.Format("exec proc_BonusOutput 'gongshiOrbumen','','{0}','','','{1}'", companyId, BonusItemID);
            //DataTable dt = sql.GetDataTableCommand(sqlstr22);
            //List<Users> userList = new List<Users>();
            //if (dt?.Rows.Count > 0)
            //{
            //    ViewBag.zimu = dt;

            //    for (int i = 0; i < dt.Rows.Count; i++)
            //    {
            //        Users us = new Users();
            //        us.Shou = dt.Rows[i]["py"].ToString();
            //        List<User> uList = new List<User>();
            //        string sqlstr23 = string.Format("select * from Employee where SpellJX like '{0}%' and CompanyID='{1}' and EmpID!='{2}'", dt.Rows[i]["py"].ToString(),companyId,userid);
            //        DataTable dt2 = sql.GetDataTableCommand(sqlstr23);
            //        if (dt2?.Rows.Count > 0)
            //        {
            //            for (int ii = 0; ii < dt2.Rows.Count; ii++)
            //            {
            //                User u = new Models.User();
            //                u.name = dt2.Rows[ii]["Name"].ToString();
            //                u.userid = dt2.Rows[ii]["EmpID"].ToString();
            //                u.photo = dt2.Rows[ii]["EmpPhotos"].ToString();
            //                u.isEmp= int.Parse(dt2.Rows[ii]["isEmp"].ToString());
            //                uList.Add(u);
            //            }
            //        }
            //        us.user = uList;
            //        userList.Add(us);
            //    }
            //}
            //else
            //{
            //    ViewBag.zimu = null;
            //}
            //ViewBag.userList = userList;
            #endregion
            return(View());
        }