当前位置: 首页>>代码示例>>C#>>正文


C# DB.reDt方法代码示例

本文整理汇总了C#中DB.reDt方法的典型用法代码示例。如果您正苦于以下问题:C# DB.reDt方法的具体用法?C# DB.reDt怎么用?C# DB.reDt使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DB的用法示例。


在下文中一共展示了DB.reDt方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ShowButton

    private void ShowButton()
    {
        int flag = 0;//用flag标记用户的当前状态,0:未值班期间,1:值班期间
        DB db = new DB();
        DateTime nowTime = DateTime.Now;
        string sqlstr = "SELECT * FROM dutyTimeTable;SELECT * FROM myDutyTime;SELECT jobskyerID,jobName FROM jobskyer";
        DataSet ds = db.reDt(sqlstr).DataSet;
        DateTime dutyInTime=new DateTime();
        DateTime dutyOutTime=new DateTime();
        //先判断签退和代班签退,签退优先于代班签退
        //判断表中是否非空
        if(ds.Tables[0].Rows.Count>0&&ds.Tables[1].Rows.Count>0&&ds.Tables[2].Rows.Count>0)
        {
            //Response.Write("1");
            for(int i=0;i<ds.Tables[1].Rows.Count;i++)
            {
                //当天有值班人为当前用户的未签退记录
                if(ds.Tables[1].Rows[i]["jobskyerID"].ToString().Trim()==Session["jobskyerID"].ToString().Trim()&&ds.Tables[1].Rows[i]["flag1"].ToString()=="2"&&Convert.ToDateTime(ds.Tables[1].Rows[i]["dutyInTime"]).ToShortDateString()==nowTime.ToShortDateString())
                {
                    //查找被值班人的理论签退时间
                    //Response.Write("...");
                    for (int j = 0; j < ds.Tables[0].Rows.Count;j++ )
                    {
                        //找到
                        if (ds.Tables[0].Rows[j]["jobskyerID"].ToString().Trim() == ds.Tables[1].Rows[i]["toJobskyerID"].ToString().Trim() && Convert.ToDateTime(ds.Tables[0].Rows[j]["dutyOutTime"]).DayOfWeek == nowTime.DayOfWeek)
                        {
                            flag = 1;
                            Session["dutyRecordID"] = ds.Tables[1].Rows[i]["dutyRecordID"].ToString();
                            dutyOutTime = Convert.ToDateTime(ds.Tables[0].Rows[j]["dutyOutTime"].ToString());
                        }
                        else
                        {
                            continue;
                        }
                        //找到才会执行下面的语句,在允许的签退范围之内时
                        if(dutyOutTime.DayOfWeek==nowTime.DayOfWeek&&differOfTime(dutyOutTime,nowTime)<=30&&differOfTime(dutyOutTime,nowTime)>=-60)
                        {
                            //从这里开始往下
                            //找到被值班人的名字
                            for (int k = 0; k < ds.Tables[2].Rows.Count;k++ )
                            {
                                if (ds.Tables[1].Rows[i]["flag2"].ToString() == "2" && ds.Tables[2].Rows[k]["jobskyerID"].ToString().Trim() == ds.Tables[1].Rows[i]["toJobskyerID"].ToString().Trim())
                                {
                                    //获得被代班人的名字传到下面签退里
                                    //判断是否在代班签退允许时间范围内,显示代班签到签退按钮
                                    Session["toJobName"] = ds.Tables[2].Rows[k]["jobName"].ToString().Trim();
                                    //Response.Write(Session["toJobName"]);
                                    Session["toJobskyerID"] = ds.Tables[1].Rows[i]["toJobskyerID"].ToString();
                                    //ImgbtnSignOut.ImageUrl="~/Image/Sign/SignOutTo.PNG";
                                    ImgbtnSignIn.Visible = true;
                                    ImgbtnSignIn.Enabled = true;
                                    lblMessage.Visible = true;
                                    //Response.Write(ds.Tables[1].Rows[i]["toJobskyerID"].ToString());
                                    if (Session["jobskyerID"].ToString().Trim() == ds.Tables[1].Rows[i]["toJobskyerID"].ToString().Trim())
                                    {
                                        ImgbtnSignIn.ImageUrl = "~/Image/Sign/SignOut.PNG";
                                        lblMessage.Text = Session["jobName"] + "正在值班";
                                    }
                                    else
                                    {
                                        ImgbtnSignIn.ImageUrl = "~/Image/Sign/SignOutTo.PNG";
                                        lblMessage.Text = Session["jobName"] + "正在给"+Session["toJobName"]+"值班";
                                    }     
                                }
                            }
                            
                        }
                            //如果在值班期间,显示值班提示信息
                        else if(dutyOutTime.DayOfWeek==nowTime.DayOfWeek&&differOfTime(nowTime,dutyInTime)>-30&&differOfTime(dutyOutTime,nowTime)>30)
                        {
                            
                            for (int k = 0; k < ds.Tables[2].Rows.Count; k++)
                            {
                                if (ds.Tables[2].Rows[k]["jobskyerID"].ToString().Trim() == ds.Tables[1].Rows[i]["toJobskyerID"].ToString().Trim())
                                {
                                    //Session["toJobName"] = ds.Tables[2].Rows[k]["jobName"].ToString().Trim();

                                    if (Session["jobskyerID"].ToString().Trim() == ds.Tables[1].Rows[i]["toJobskyerID"].ToString().Trim())
                                    {
                                        
                                        //flag = 1;
                                        lblMessage.Visible = true;
                                        lblMessage.Text =  Session["jobName"].ToString()+ "正在值班,未到签退时间";
                                        DLSignInTo.Visible = false;
                                        ImgbtnSignIn.Enabled = false;
                                        ImgbtnSignIn.Visible = false;
                                    }
                                    else
                                    {
                                        //flag = 1;
                                        lblMessage.Visible = true;
                                        ImgbtnSignIn.Enabled = false;
                                        ImgbtnSignIn.Visible = false;
                                        DLSignInTo.Visible = false;
                                        //DLSignInTo.Enabled = false;
                                        //DLSignInTo.Visible = false;
                                        //DLSignInTo.SelectedValue = Session["toJobName"].ToString();
                                        Session["toJobName"] = ds.Tables[2].Rows[k]["jobName"].ToString();
                                        lblMessage.Text = Session["jobName"].ToString() + "正在给" + Session["toJobName"] + "值班,未到签退时间";
                                       }
//.........这里部分代码省略.........
开发者ID:LiuYingyingCSU,项目名称:JobskyOA,代码行数:101,代码来源:SignInAndOut.aspx.cs

示例2: btnLogin_Click

    //登录按钮
    protected void btnLogin_Click(object sender, ImageClickEventArgs e)
    {
        lblFailText.Visible = false;
        if (String.IsNullOrEmpty(UserName.Text))
        {

            lblUser.Visible = true;
        }
        else if (String.IsNullOrEmpty(Password.Text))
        {
            lblPwd.Visible = true;
        }
        else
        {
            HttpCookie ID = new HttpCookie("jobskyerID");
            HttpCookie Name = new HttpCookie("jobName");
            if (RememberMe.Checked == true)
            {

                ID.Values.Add("UserID", UserName.Text.Trim());
                Name.Values.Add("UserName", Password.Text.Trim());
                Response.Cookies.Add(ID);
                Response.Cookies.Add(Name);
                ID.Expires = DateTime.Now.AddMonths(6);
                Name.Expires = DateTime.Now.AddMonths(6);
            }
            DB db = new DB();
            string jobskyerID = this.UserName.Text.Trim();
            string passWord = this.Password.Text.Trim();
            //string role = "0";
            //role = jobRole.ToString();
            //Response.Write(role);
            try
            {
                DataTable dt = db.reDt("select jobskyerID,password,jobRole,jobName from jobskyer");
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    if (dt.Rows[i]["jobskyerID"].ToString() == jobskyerID && dt.Rows[i]["password"].ToString() == passWord)
                    {
                        Session["jobskyerID"] = dt.Rows[i]["jobskyerID"];                //将用户ID存入Session["jobskyerID"]
                        Session["jobRole"] = dt.Rows[i]["jobRole"];                  //将用户权限存入Session["jobRole"]中
                        Session["jobName"] = dt.Rows[i]["jobName"];
                        FormsAuthentication.RedirectFromLoginPage(Session["jobName"].ToString(), false);
                        string jobName = dt.Rows[i]["jobName"].ToString();
                        if (Session["jobRole"].ToString() == "0")
                        {
                            if (role.ToString() == "1")
                            {
                                //this.lblFailText.Text = "请以正确身份登录";
                                Response.Redirect("~/JsCommon/Login.aspx");
                                //this.lblFailText.Visible = true;
                            }
                            else if (role.ToString() == "0")
                            {
                                Response.Redirect("~/JsCommon/JsCommonMain.aspx?Name=" + jobName + ""); //跳转至一般用户界面,并传递参数,登录人员名称
                            }
                            else
                            {
                                Response.Redirect("~/JsCommon/JsCommonMain.aspx?Name=" + jobName + "");
                                //lblFailText.Text = "请选择角色身份";
                                //this.lblFailText.Visible = true;
                            }
                        }
                        else if (Session["jobRole"].ToString() == "1")
                        {
                            if (role.ToString() == "1")
                            {
                                //Response.Write("管理员");
                                Response.Redirect("~/JsManager/JsManagerMain.aspx?Name=" + jobName + "");  //跳转至管理人员界面
                            }
                            else if (role.ToString() == "0")
                            {
                                //Response.Write("普通用户");
                                Response.Redirect("~/JsCommon/JsCommonMain.aspx?Name=" + jobName + "");  //跳转至超级用户界面
                            }
                            else
                            {
                                //lblFailText.Text = "请选择角色身份";
                                //lblFailText.Visible = true;
                                Response.Redirect("~/JsCommon/Login.aspx");
                            }
                        }
                    }
                    else if (i == dt.Rows.Count - 1)
                    {
                        lblFailText.Visible = true;
                        lblFailText.Text = "用户名或密码错误";
                    }
                }
            }
            catch (Exception ex)
            {
                Response.Write(ex.ToString());
            }
            finally
            {

            }
        }
//.........这里部分代码省略.........
开发者ID:LiuYingyingCSU,项目名称:JobskyOA,代码行数:101,代码来源:Login.aspx.cs


注:本文中的DB.reDt方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。