Ejemplo n.º 1
0
        public int AddChance(Model.Chances chances)
        {
            chances.ChanCreateDate = DateTime.Now;
            int id = -1;

            if (DalBase.Insert(chances) > 0)
            {
                id = Convert.ToInt32(DalBase.GetMax <Model.Chances>());
            }
            return(id);
        }
Ejemplo n.º 2
0
        public int UpdChanDue(Model.Chances chance)
        {
            chance.ChanDueDate = DateTime.Now;

            return(DalBase.Updata(chance));
        }
Ejemplo n.º 3
0
        public int UpdChance(Model.Chances chances)
        {
            //机会创建人id
            string sql = string.Format(@"select ChanCreateMan from Chances where ChanID=@ChanID");

            SqlParameter[] sp = new SqlParameter[] {
                new SqlParameter("@ChanID", chances.ChanID)
            };
            int crid = DalBase.SelectObj(sql, sp);

            //查询机会状态
            string sql5 = string.Format(@"select ChanState from Chances where ChanID=@ChanID");

            SqlParameter[] sp5 = new SqlParameter[] {
                new SqlParameter("@ChanID", chances.ChanID)
            };
            int csid = DalBase.SelectObj(sql5, sp5);

            int cdid = 0;

            if (csid != 1)
            {
                //机会指派人id
                string         sql3 = string.Format(@"select ChanDueMan from Chances where ChanID=@ChanID");
                SqlParameter[] sp3  = new SqlParameter[] {
                    new SqlParameter("@ChanID", chances.ChanID)
                };
                cdid = DalBase.SelectObj(sql3, sp3);
            }
            //当前登录人id
            string UserLName = Session["UserLName"].ToString();
            string sql1      = string.Format(@"select UserID from Users where UserLName=@UserLName");

            SqlParameter[] sp1 = new SqlParameter[] {
                new SqlParameter("@UserLName", UserLName)
            };
            int uid = DalBase.SelectObj(sql1, sp1);

            //当前登录人角色id
            string sql2 = string.Format(@"select RoleID from Users where UserLName=@UserLName");

            SqlParameter[] sp2 = new SqlParameter[] {
                new SqlParameter("@UserLName", UserLName)
            };
            int rid = DalBase.SelectObj(sql2, sp2);

            if (rid <= 2)
            {
                DalBase.Updata(chances);
            }
            else if (rid == 3)
            {
                if (crid == uid)
                {
                    DalBase.Updata(chances);
                }
                else if (cdid == uid)
                {
                    DalBase.Updata(chances);
                }
                else
                {
                    return(-1);
                }
            }

            return(1);
        }