예제 #1
0
    public PagedList <PathLabModel> GetAllPathLabPaginated(int skip, int take, string order, string where)
    {
        var pathlabs = new List <PathLabModel>();
        var orderBy  = string.IsNullOrEmpty(order) ? " order by pm.created_on desc " : order;
        var query    = "select pm.*, cm.city_name from path_lab_master pm, city_master cm where pm.city_id = cm.city_id and  pm.is_active='y' " + where + orderBy + " limit " + take + " offset " + skip;
        var rows     = new DataAccessManager().ExecuteSelectQuery(query);

        if (rows != null && rows.Count > 0)
        {
            foreach (DataRow r in rows)
            {
                var pathlab = new PathLabModel();
                var props   = typeof(PathLabModel).GetProperties();

                foreach (var prop in props)
                {
                    var ignore = Attribute.IsDefined(prop, typeof(IgnoreSelect));
                    if (!ignore)
                    {
                        var    attribute   = prop.GetCustomAttributes(typeof(DisplayNameAttribute), true).Cast <DisplayNameAttribute>().Single();
                        string displayName = attribute.DisplayName;

                        var    value = r[displayName];
                        var    pType = prop.PropertyType;
                        object v     = null;
                        if (pType == typeof(bool))
                        {
                            v = value.ToString() == "y";
                        }
                        else
                        {
                            v = value == null ? null : value;
                        }

                        var variable = prop.SetMethod;

                        if (!r.IsNull(displayName))
                        {
                            variable.Invoke(pathlab, new object[] { v });
                        }
                    }
                }
                pathlabs.Add(pathlab);
            }
        }
        query = "select count(*) from path_lab_master pm, city_master cm where pm.city_id = cm.city_id and  pm.is_active='y' " + where;
        var totalCount = new DataAccessManager().ExecuteScalar(query);
        var count      = totalCount != null?int.Parse(totalCount.ToString()) : 0;

        var result = new PagedList <PathLabModel>()
        {
            TotalCount = count, Data = pathlabs
        };

        return(result);
    }
예제 #2
0
    public List <PathLabModel> GetAllPathLab()
    {
        var pathlabs = new List <PathLabModel>();
        var query    = "select * from path_lab_master where is_active='y' order by created_on desc";
        var rows     = new DataAccessManager().ExecuteSelectQuery(query);

        if (rows != null && rows.Count > 0)
        {
            foreach (DataRow r in rows)
            {
                var pathlab = new PathLabModel();
                var props   = typeof(PathLabModel).GetProperties();

                foreach (var prop in props)
                {
                    var ignore = Attribute.IsDefined(prop, typeof(IgnoreInsert));
                    if (!ignore)
                    {
                        var    attribute   = prop.GetCustomAttributes(typeof(DisplayNameAttribute), true).Cast <DisplayNameAttribute>().Single();
                        string displayName = attribute.DisplayName;

                        var    value = r[displayName];
                        var    pType = prop.PropertyType;
                        object v     = null;
                        if (pType == typeof(bool))
                        {
                            v = value.ToString() == "y";
                        }
                        else
                        {
                            v = value == null ? null : value;
                        }

                        var variable = prop.SetMethod;

                        if (!r.IsNull(displayName))
                        {
                            variable.Invoke(pathlab, new object[] { v });
                        }
                    }
                }
                pathlabs.Add(pathlab);
            }
        }
        return(pathlabs);
    }
예제 #3
0
    protected void SubmitPathLab(object sender, EventArgs e)
    {
        try
        {
            var pathLab = new PathLabModel();

            pathLab.City    = int.Parse(city.Value);
            pathLab.Email   = email.Value;
            pathLab.Mobile  = mobile.Value;
            pathLab.Address = address.Value;

            if (hrs24.Checked)
            {
                pathLab.Timing = "24 hrs";
            }
            else
            {
                pathLab.Timing = timingFrom.Value + " to " + timingTo.Value;
            }

            pathLab.OpeningYear = opening_year.Value;

            pathLab.Name     = lab_name.Value;
            pathLab.IsActive = true;
            pathLab.Created  = DateTime.UtcNow.AddHours(5).AddMinutes(30);

            if (Request.Files.Count > 0)
            {
                var files = new List <string>();
                for (var i = 0; i < Request.Files.Count; i++)
                {
                    HttpPostedFile f = Request.Files[i];
                    if (f.ContentLength > 0)
                    {
                        var extension = Path.GetExtension(f.FileName);
                        var fileName  = Guid.NewGuid().ToString() + "." + extension;
                        files.Add(fileName);

                        string pathToSave_100 = HttpContext.Current.Server.MapPath("~/photo/" + fileName);
                        f.SaveAs(pathToSave_100);
                    }
                }
                if (files.Count > 0)
                {
                    pathLab.Images = string.Join(" ", files);
                }
            }

            var sqlQuery = new Helper().GetInsertQuery <PathLabModel>(pathLab);
            if (!string.IsNullOrWhiteSpace(path_lab_id.Value))
            {
                pathLab.Id = int.Parse(path_lab_id.Value);
                sqlQuery   = new Helper().GetUpdateQuery <PathLabModel>(pathLab);
            }

            var dam = new DataAccessManager().ExecuteInsertUpdateQuery(sqlQuery);
            if (dam)
            {
                msg = "PathLab Added Successfully!";
                Response.Redirect("PathLab", true);
            }
        }
        catch (Exception ex)
        {
            msg          = "Failed To Add Doctor!";
            action.Value = msg;
        }
    }