Esempio n. 1
0
        public List <clsListdata> GetdataJSON(string value)
        {
            List <clsListdata> lstdata = new List <clsListdata>();

            try
            {
                DataTable dt = new DataTable();
                dt.Columns.Add("ID");
                dt.Columns.Add("Name");
                dt.Rows.Add("1", "Devan");
                dt.Rows.Add("2", "Irfan");
                dt.Rows.Add("3", "Guru");
                dt.Rows.Add("4", "Tamil");
                dt.Rows.Add("5", "Shankar");

                if (value.ToLower() == "all")
                {
                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        clsListdata clsdata = new clsListdata();
                        clsdata.ID           = dt.Rows[i]["ID"].ToString();
                        clsdata.Name         = dt.Rows[i]["Name"].ToString();
                        clsdata.ErrorMessage = "";
                        lstdata.Add(clsdata);
                    }
                }
                else
                {
                    DataTable dtfilter = new DataTable();
                    DataRow[] dr;
                    dr = dt.Select("ID='" + value + "'");
                    if (dr.Length > 0)
                    {
                        clsListdata clsdata = new clsListdata();
                        clsdata.ID           = dr[0].ItemArray[0].ToString();
                        clsdata.Name         = dr[0].ItemArray[1].ToString();
                        clsdata.ErrorMessage = "";
                        lstdata.Add(clsdata);
                    }
                    else
                    {
                        clsListdata clsdata = new clsListdata();
                        clsdata.ID           = "";
                        clsdata.Name         = "";
                        clsdata.ErrorMessage = "No Record Found..";
                        lstdata.Add(clsdata);
                    }
                }
            }
            catch (Exception ex)
            {
                clsListdata clsdata = new clsListdata();
                clsdata.ID           = "";
                clsdata.Name         = "";
                clsdata.ErrorMessage = ex.Message.ToString();
                lstdata.Add(clsdata);
            }
            return(lstdata);
        }
Esempio n. 2
0
        public List <clsListdata> CreateNewUser(string name, string mobile, string email, string address, string password)
        {
            string        c   = ConfigurationManager.ConnectionStrings["mycon"].ConnectionString;
            SqlConnection con = new SqlConnection(c);


            List <clsListdata> lstdata = new List <clsListdata>();

            try
            {
                SqlCommand cmd = new SqlCommand("exec CreateNewUser @name,@mobile,@email,@address,@pwd", con);
                cmd.Parameters.AddWithValue("@name", name);
                cmd.Parameters.AddWithValue("@Mobile", mobile);
                cmd.Parameters.AddWithValue("@Email", email);
                cmd.Parameters.AddWithValue("@address", address);
                cmd.Parameters.AddWithValue("@pwd", password);

                cmd.CommandType = CommandType.Text;
                SqlDataAdapter da = new SqlDataAdapter();
                da.SelectCommand = cmd;
                con.Open();


                DataTable dt = new DataTable();
                da.Fill(dt);

                con.Close();



                if (dt.Rows[0]["SuccessMessage"].ToString() != "")
                {
                    clsListdata clsdata = new clsListdata();
                    clsdata.SuccessOrError = dt.Rows[0]["SuccessOrError"].ToString();
                    clsdata.SuccessMessage = dt.Rows[0]["SuccessMessage"].ToString();
                    clsdata.ErrorMessage   = "";
                    lstdata.Add(clsdata);
                }
                else
                {
                    clsListdata clsdata = new clsListdata();
                    clsdata.SuccessOrError = dt.Rows[0]["SuccessOrError"].ToString();
                    clsdata.SuccessMessage = "";
                    clsdata.ErrorMessage   = dt.Rows[0]["EMessage"].ToString();
                    lstdata.Add(clsdata);
                }
            }
            catch (Exception ex)
            {
                clsListdata clsdata = new clsListdata();
                clsdata.SuccessOrError = "";
                clsdata.SuccessMessage = "";
                clsdata.ErrorMessage   = ex.Message.ToString();
                lstdata.Add(clsdata);
            }
            return(lstdata);
        }
Esempio n. 3
0
 public List <clsLeadDataSuccess> PostdataJSON(clsListdata p)
 {
     try
     {
         List <clsLeadDataSuccess> lst = new List <clsLeadDataSuccess>();
         clsLeadDataSuccess        cls = new clsLeadDataSuccess();
         cls.SuccessMessage = p.imgString;
         cls.ErrorMessage   = "";
         lst.Add(cls);
         return(lst);
     }
     catch (Exception ex)
     {
         List <clsLeadDataSuccess> lst = new List <clsLeadDataSuccess>();
         clsLeadDataSuccess        cls = new clsLeadDataSuccess();
         cls.SuccessMessage = "";
         cls.ErrorMessage   = ex.Message.ToString();
         lst.Add(cls);
         return(lst);
     }
 }