示例#1
0
    protected void Button1_Click(object sender, EventArgs e)
    {
        WebApplication1.dbConnection bdc = new WebApplication1.dbConnection();
        String    Str = "SELECT [Name],[Id],[UserName],[Password],[IsAdmin],[UserType],[VendorID],[Deleted],WorkshopId,isnull(JurisdictionID,0) as JurisdictionID,isnull(DeliveryId,0) as DeliveryId,isnull(FranchiseeId,0) as FranchiseeId FROM [dbo].[Users] where [UserName]='" + txtId.Text.Replace("'", "''") + "' And [Password]='" + txtpass.Text.Replace("'", "''") + "' And Deleted = 0";
        DataTable st  = bdc.GetDataTable(Str);

        if (st.Rows.Count > 0)
        {
            Session["KeepAlive"] = true;
            if (!Response.Cookies.AllKeys.Contains("TUser"))
            {
                HttpCookie aCookie = new HttpCookie("TUser");
                aCookie["Id"]       = st.Rows[0]["Id"].ToString();
                aCookie["UserName"] = st.Rows[0]["Name"].ToString();
                // aCookie["mobile_number"] = st.Rows[0]["mobile_number"].ToString();
                aCookie["VendorId"]       = st.Rows[0]["VendorID"].ToString();
                aCookie["WorkshopId"]     = st.Rows[0]["WorkshopId"].ToString();
                aCookie["IsAdmin"]        = st.Rows[0]["IsAdmin"].ToString();
                aCookie["JurisdictionID"] = st.Rows[0]["JurisdictionID"].ToString();
                aCookie["UserType"]       = st.Rows[0]["UserType"].ToString();
                aCookie["DeliveryId"]     = st.Rows[0]["DeliveryId"].ToString();
                aCookie["FranchiseeId"]   = st.Rows[0]["FranchiseeId"].ToString();
                aCookie.Expires           = DateTime.Now.AddHours(24);

                Response.Cookies.Add(aCookie);

                int userId = 0;
                int.TryParse(Request.Cookies["TUser"]["Id"], out userId);
                try
                {
                    dbConnection dbcon      = new dbConnection();
                    int          workshopId = 0;
                    int.TryParse(Request.Cookies["TUser"]["WorkshopId"], out workshopId);
                    string    StrPages = "";
                    DataTable dt       = dbcon.GetDataTable("SELECT Pages.PageUrl FROM Role INNER JOIN User_Role_Mapping ON Role.Id = User_Role_Mapping.RoleId INNER JOIN Users ON User_Role_Mapping.UserId = Users.Id INNER JOIN Role_Page_Mapping ON Role.Id = Role_Page_Mapping.RoleId INNER JOIN Pages ON Role_Page_Mapping.PageId = Pages.Id where Users.Id=" + userId + " and Users.WorkshopId=" + workshopId);
                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        StrPages += dt.Rows[i][0].ToString();
                    }
                    Application[workshopId + "-pages-" + userId] = StrPages;
                    try
                    {
                        // string WorkshopId = HttpContext.Current.Request.Cookies["TUser"]["WorkshopId"];
                        //string UserId = HttpContext.Current.Request.Cookies["TUser"]["Id"];
                        UserActivity objUserAct = new UserActivity();
                        objUserAct.InsertUserActivity(st.Rows[0]["UserName"].ToString() + " Loged In to system on : " + dbcon.getindiantime().ToString("MM-dd-yyyy HH:mm:ss tt"), userId.ToString(), workshopId.ToString(), "", "Common", "LogedIn");
                    }
                    catch (Exception E) { }
                }
                catch (Exception E)
                { }
                if (Session["URL"] != null)
                {
                    string str = Session["URL"].ToString();
                    Session["URL"] = null;
                    Response.Redirect(str);
                }
                Response.Redirect("Home.aspx");
            }
            else
            {
                var aCookie = Response.Cookies.Get("TUser");
                aCookie.Value   = st.Rows[0]["Id"].ToString();
                aCookie.Expires = DateTime.Now.AddHours(24);
                // Response.Cookies.Add(aCookie);
            }
            Literal1.Text = "";
        }
        else
        {
            Literal1.Text = "<p class='login-box-msg'>Incorrect username or password</p>";
        }
    }
示例#2
0
    protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
            WebApplication1.dbConnection dbcon = new WebApplication1.dbConnection();
            if (!String.IsNullOrWhiteSpace(Request.QueryString["Id"]))
            {
                startdate.Value = dbcon.getindiantime().AddDays(3).ToString("dd/MMM/yyyy");
                DataTable dt = dbcon.GetDataTableWithParams("SELECT  isnull(Vehicle_Model.Name,'-') +' ,'+ isnull(Vehicle_Brand.Name,'-') + ' ,'+ isnull(Vehicle.Number,'-') as Vehicle,isnull(Customer.Name,'-')+' , '+isnull(Customer.Mobile,'-') AS Customer,isnull(CustomerReviewComment,'') as Cmt,CustomerNextReviewDate as dt,jobcard.Type FROM   Customer RIGHT OUTER JOIN JobCard ON Customer.Id = JobCard.Customer_Id LEFT OUTER JOIN Vehicle LEFT OUTER JOIN Vehicle_Variant ON Vehicle.Vehicle_Variant_Id = Vehicle_Variant.Id LEFT OUTER JOIN Vehicle_Brand ON Vehicle.Vehicle_Brand_Id = Vehicle_Brand.Id LEFT OUTER JOIN Vehicle_Model ON Vehicle.Vehicle_Model_Id = Vehicle_Model.Id ON JobCard.Vehicle_Id = Vehicle.Id where JobCard.id>0 And isnull(IsGatePassGenerated,0) =1 and jobcard.id=@1", new string[] { Request.QueryString["Id"] });
                if (dt != null && dt.Rows.Count > 0)
                {
                    txtV.InnerHtml    = dt.Rows[0][0].ToString();
                    txtCust.InnerHtml = dt.Rows[0][1].ToString();
                    //txtc.Value = dt.Rows[0][2].ToString();
                    try
                    {
                        //if (dt.Rows[0][3] != null)
                        //{
                        //    if (!String.IsNullOrWhiteSpace(dt.Rows[0][3].ToString()))
                        //    {
                        //        DateTime dt1 = Convert.ToDateTime(dt.Rows[0][3].ToString());
                        //        startdate.Value = dt1.ToString("dd/MMM/yyyy");
                        //        txttime.Value = dt1.ToString("hh:MM tt");
                        //    }
                        //}
                        if (dt.Rows[0][4] != null)
                        {
                            if (!String.IsNullOrWhiteSpace(dt.Rows[0][4].ToString()))
                            {
                                if (!dt.Rows[0][4].ToString().Equals("2"))
                                {
                                    lnkInsurance.Visible = false;
                                }
                            }
                        }
                    }
                    catch (Exception E) { }
                }
                dt = dbcon.GetDataTableWithParams("Select Notes from  CustomerNote where ISNULL(IsDeleted,0)=0 and JobCard_id=@1", new string[] { Request.QueryString["Id"] });
                if (dt != null && dt.Rows.Count > 0)
                {
                    string Str = "<ul style='margin-left: 5%;'>";
                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        Str += "<li>" + dt.Rows[i][0].ToString() + "</li>";
                    }
                    Str            += "</ul>";
                    txtcd.InnerHtml = Str;
                    //string Str = "";
                    //for (int i = 0; i < dt.Rows.Count; i++)
                    //{
                    //    Str += "" + dt.Rows[i][0].ToString() + (i >= (dt.Rows.Count-1)?"": ",");
                    //}
                    ////Str += "</ul>";
                    //txtcd.InnerHtml = Str;
                }
            }
            if (Request.QueryString["TEA"] != null)
            {
                txtTEA.InnerHtml = "Estimate  : ₹ " + Request.QueryString["TEA"];
            }
            if (Request.QueryString["TPA"] != null)
            {
                txtTPA.InnerHtml = "Paid   : ₹ " + Request.QueryString["TPA"];
            }

            DataTable dt1 = dbcon.GetDataTableWithParams("SELECT  CONVERT(varchar(17), [DOC] , 113 ) as Date,[Comment],isnull((Select CustomerReviewMaster.Value from CustomerReviewMaster where Id=CustomerReviewMasterId),'') as Review FROM [dbo].[CustomerReviewCallHistory] where jobcardid=@1", new string[] { Request.QueryString["Id"] });
            if (dt1.Rows.Count > 0)
            {
                GridView1.Caption    = "History";
                GridView1.DataSource = dt1;
                GridView1.DataBind();
            }
            else
            {
                GridView1.Caption    = "";
                GridView1.DataSource = dt1;
                GridView1.DataBind();
            }
        }
        catch (Exception E) { }
    }