Exemplo n.º 1
0
        //public static void CreateTables()
        //{


        //    using (var cmd = new SQLiteCommand(con))
        //    {

        //        cmd.CommandText = @SQL_CREATE_USERS;
        //        cmd.ExecuteNonQuery();

        //        cmd.CommandText = @SQL_CREATE_VILLAGES;
        //        cmd.ExecuteNonQuery();

        //        cmd.CommandText = @SQL_DELETE_ZSTANDARDS;
        //        cmd.ExecuteNonQuery();

        //        //cmd.CommandText = @SQL_DELETE_FORMS;
        //        //cmd.ExecuteNonQuery();

        //    };
        //    con.Close();
        //}

        //public static void InsertTestUser(List<users> users)
        //{


        //    using (con)
        //    {
        //        con.Open();


        //        using (var cmd = con.CreateCommand())
        //        {
        //            cmd.CommandText = "INSERT INTO users (username, password) VALUES(@username, @password)";

        //            for (int i = 0; i < users.Count; i++)
        //            {
        //                cmd.Parameters.Clear();
        //                cmd.Parameters.AddWithValue("@username", users[i].username);
        //                cmd.Parameters.AddWithValue("@password", users[i].password);

        //                cmd.ExecuteNonQuery();
        //            }
        //        }

        //        con.Close();
        //    }
        //}



        public void InsertForm(forms_data form_data)
        {
            var    rdnum = new System.Random();
            string ml    = DateTime.Now.ToString("mmss");

            int    random = rdnum.Next(100);
            string abc    = ml + random;
            string def    = abc.Substring(1, 3);
            int    id     = Convert.ToInt16(def);

            using (con)
            {
                try
                {
                    con.Open();


                    using (var cmd = con.CreateCommand())
                    {
                        cmd.CommandText = "INSERT INTO forms (_id,f1,f2,f3,f4,f5,f6,f7) VALUES (@_id,@f1,@f2,@f3,@f4,@f5,@f6,@f7)";


                        cmd.Parameters.Clear();

                        cmd.Parameters.AddWithValue("_id", id);
                        cmd.Parameters.AddWithValue("f1", form_data.f1);
                        cmd.Parameters.AddWithValue("f2", form_data.f2);
                        cmd.Parameters.AddWithValue("f3", form_data.f3);
                        cmd.Parameters.AddWithValue("f4", form_data.f4);
                        cmd.Parameters.AddWithValue("f5", form_data.f5);
                        cmd.Parameters.AddWithValue("f6", form_data.f6);
                        cmd.Parameters.AddWithValue("f7", form_data.f7);

                        //cmd.Parameters.AddWithValue("deviceid", forms_data.deviceid);
                        //cmd.Parameters.AddWithValue("endingdatetime", forms_data.endingdatetime);
                        //cmd.Parameters.AddWithValue("gpsacc", forms_data.gpsacc);
                        //cmd.Parameters.AddWithValue("gpsdate", forms_data.gpsdate);
                        //cmd.Parameters.AddWithValue("gpslat", forms_data.gpslat);
                        //cmd.Parameters.AddWithValue("gpslng", forms_data.gpslng);
                        //cmd.Parameters.AddWithValue("istatus", forms_data.istatus);
                        //cmd.Parameters.AddWithValue("istatus96x", forms_data.istatus96x);
                        //cmd.Parameters.AddWithValue("sysdate", forms_data.sysdate);
                        //cmd.Parameters.AddWithValue("tagid", forms_data.tagid);
                        //cmd.Parameters.AddWithValue("username", forms_data.username);


                        cmd.ExecuteNonQuery();
                        MessageBox.Show("SUCCESS!", "Form saved!");
                    }

                    con.Close();
                }
                catch (Exception e)
                {
                    MessageBox.Show("ERROR!", "Form was not saved. " + "\n" + e.Message);
                }
            }
        }
Exemplo n.º 2
0
        public List <forms_data> UploadForms()
        {
            List <forms_data> froms = new List <forms_data>();


            try
            {
                con.Open();
                using (var cmd = con.CreateCommand())
                {
                    cmd.CommandText = "select * from forms where synced is Null";
                    r = cmd.ExecuteReader();


                    while (r.Read())
                    {
                        forms_data f = new forms_data();
                        f._id            = r["_id"].ToString();
                        f._uid           = r["_uid"].ToString();
                        f.appversion     = r["appversion"].ToString();
                        f.f1             = r["f1"].ToString();
                        f.f2             = r["f2"].ToString();
                        f.f3             = r["f3"].ToString();
                        f.f4             = r["f4"].ToString();
                        f.f5             = r["f5"].ToString();
                        f.f6             = r["f6"].ToString();
                        f.f7             = r["f7"].ToString();
                        f.deviceid       = r["deviceid"].ToString();
                        f.endingdatetime = r["endingdatetime"].ToString();
                        f.gpsacc         = r["gpsacc"].ToString();
                        f.gpsdate        = r["gpsdate"].ToString();
                        f.gpslat         = r["gpslat"].ToString();
                        f.gpslng         = r["gpslng"].ToString();
                        f.istatus        = r["istatus"].ToString();
                        f.istatus96x     = r["istatus96x"].ToString();
                        f.sysdate        = r["sysdate"].ToString();


                        f.tagid    = r["tagid"].ToString();
                        f.username = r["username"].ToString();



                        //
                        froms.Add(f);
                    }
                    r.Close();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }

            return(froms);
        }
Exemplo n.º 3
0
        public void Insert_Form()
        {
            control_value();
            forms_data fr = new forms_data();

            fr.f1 = f1;
            fr.f2 = f2;
            fr.f3 = dateTime_dob.Value.ToString("MM/dd/yyyy");
            fr.f4 = f4;
            fr.f5 = f5;
            fr.f6 = f6;
            fr.f7 = f7;
            db.InsertForm(fr);
        }
Exemplo n.º 4
0
        public List <forms_data> GetForms()
        {
            List <forms_data> froms = new List <forms_data>();


            try
            {
                con.Open();
                using (var cmd = con.CreateCommand())
                {
                    cmd.CommandText = "select * from forms ";
                    r = cmd.ExecuteReader();


                    while (r.Read())
                    {
                        forms_data f = new forms_data();

                        f.f1 = r["f1"].ToString();
                        f.f2 = r["f2"].ToString();
                        f.f3 = r["f3"].ToString();
                        f.f4 = r["f4"].ToString();
                        f.f5 = r["f5"].ToString();
                        f.f6 = r["f6"].ToString();
                        f.f7 = r["f7"].ToString();



                        //
                        froms.Add(f);
                    }
                    r.Close();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }

            return(froms);
        }
Exemplo n.º 5
0
        public List <forms_data> fetchData()
        {
            CConnection cn = new CConnection();

            List <forms_data> forms = new List <forms_data>();

            try
            {
                SQLiteDataAdapter da = new SQLiteDataAdapter("select * from camp_patient_dtl where synced is null or synced = ''", cn.cn);
                DataSet           ds = new DataSet();
                da.Fill(ds);


                for (int a = 0; a <= ds.Tables[0].Rows.Count - 1; a++)
                {
                    forms_data fd = new forms_data();

                    fd._id      = ds.Tables[0].Rows[a]["id"].ToString();
                    fd.deviceid = SystemInformation.ComputerName;
                    fd.sysdate  = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                    fd.id       = ds.Tables[0].Rows[a]["id"].ToString();
                    fd.form_id  = ds.Tables[0].Rows[a]["form_id"].ToString();
                    fd.mh01     = ds.Tables[0].Rows[a]["mh01"].ToString();
                    fd.mh02     = ds.Tables[0].Rows[a]["mh02"].ToString();
                    fd.mh03     = ds.Tables[0].Rows[a]["mh03"].ToString();
                    fd.mh04     = ds.Tables[0].Rows[a]["mh04"].ToString();
                    fd.mh05     = ds.Tables[0].Rows[a]["mh05"].ToString();
                    fd.mh06     = ds.Tables[0].Rows[a]["mh06"].ToString();
                    fd.mh07     = ds.Tables[0].Rows[a]["mh07"].ToString();
                    fd.mh08     = ds.Tables[0].Rows[a]["mh08"].ToString();
                    fd.mh09y    = ds.Tables[0].Rows[a]["mh09y"].ToString();
                    fd.mh09m    = ds.Tables[0].Rows[a]["mh09m"].ToString();
                    fd.mh09d    = ds.Tables[0].Rows[a]["mh09d"].ToString();
                    fd.mh010    = ds.Tables[0].Rows[a]["mh010"].ToString();

                    fd.mh010a = ds.Tables[0].Rows[a]["mh010a"].ToString();

                    fd.mh01101 = ds.Tables[0].Rows[a]["mh01101"].ToString();
                    fd.mh01102 = ds.Tables[0].Rows[a]["mh01102"].ToString();
                    fd.mh01103 = ds.Tables[0].Rows[a]["mh01103"].ToString();

                    fd.mh012     = ds.Tables[0].Rows[a]["mh012"].ToString();
                    fd.chkWeight = ds.Tables[0].Rows[a]["chkWeight"].ToString();


                    fd.mh013     = ds.Tables[0].Rows[a]["mh013"].ToString();
                    fd.mh014     = ds.Tables[0].Rows[a]["mh014"].ToString();
                    fd.mh015     = ds.Tables[0].Rows[a]["mh015"].ToString();
                    fd.chkHeight = ds.Tables[0].Rows[a]["chkHeight"].ToString();
                    fd.mh016     = ds.Tables[0].Rows[a]["mh016"].ToString();
                    fd.chkMUAC   = ds.Tables[0].Rows[a]["chkMUAC"].ToString();

                    fd.mh011 = ds.Tables[0].Rows[a]["mh011"].ToString();


                    fd.mh01701   = ds.Tables[0].Rows[a]["mh01701"].ToString();
                    fd.mh01702   = ds.Tables[0].Rows[a]["mh01702"].ToString();
                    fd.mh01703   = ds.Tables[0].Rows[a]["mh01703"].ToString();
                    fd.mh01704   = ds.Tables[0].Rows[a]["mh01704"].ToString();
                    fd.mh01705   = ds.Tables[0].Rows[a]["mh01705"].ToString();
                    fd.mh017077  = ds.Tables[0].Rows[a]["mh017077"].ToString();
                    fd.mh017077x = ds.Tables[0].Rows[a]["mh017077x"].ToString();


                    fd.mh01801   = ds.Tables[0].Rows[a]["mh01801"].ToString();
                    fd.mh01802   = ds.Tables[0].Rows[a]["mh01802"].ToString();
                    fd.mh01803   = ds.Tables[0].Rows[a]["mh01803"].ToString();
                    fd.mh01804   = ds.Tables[0].Rows[a]["mh01804"].ToString();
                    fd.mh01805   = ds.Tables[0].Rows[a]["mh01805"].ToString();
                    fd.mh01806   = ds.Tables[0].Rows[a]["mh01806"].ToString();
                    fd.mh01807   = ds.Tables[0].Rows[a]["mh01807"].ToString();
                    fd.mh01808   = ds.Tables[0].Rows[a]["mh01808"].ToString();
                    fd.mh01809   = ds.Tables[0].Rows[a]["mh01809"].ToString();
                    fd.mh018010  = ds.Tables[0].Rows[a]["mh018010"].ToString();
                    fd.mh018011  = ds.Tables[0].Rows[a]["mh018011"].ToString();
                    fd.mh018012  = ds.Tables[0].Rows[a]["mh018012"].ToString();
                    fd.mh018013  = ds.Tables[0].Rows[a]["mh018013"].ToString();
                    fd.mh018014  = ds.Tables[0].Rows[a]["mh018014"].ToString();
                    fd.mh018015  = ds.Tables[0].Rows[a]["mh018015"].ToString();
                    fd.mh018016  = ds.Tables[0].Rows[a]["mh018016"].ToString();
                    fd.mh018077  = ds.Tables[0].Rows[a]["mh018077"].ToString();
                    fd.mh018077x = ds.Tables[0].Rows[a]["mh018077x"].ToString();

                    fd.chkNoneDiag = ds.Tables[0].Rows[a]["chkNoneDiag"].ToString();


                    fd.mh01901   = ds.Tables[0].Rows[a]["mh01901"].ToString();
                    fd.mh01902   = ds.Tables[0].Rows[a]["mh01902"].ToString();
                    fd.mh01903   = ds.Tables[0].Rows[a]["mh01903"].ToString();
                    fd.mh01904   = ds.Tables[0].Rows[a]["mh01904"].ToString();
                    fd.mh01905   = ds.Tables[0].Rows[a]["mh01905"].ToString();
                    fd.mh01906   = ds.Tables[0].Rows[a]["mh01906"].ToString();
                    fd.mh01907   = ds.Tables[0].Rows[a]["mh01907"].ToString();
                    fd.mh01908   = ds.Tables[0].Rows[a]["mh01908"].ToString();
                    fd.mh01909   = ds.Tables[0].Rows[a]["mh01909"].ToString();
                    fd.mh019010  = ds.Tables[0].Rows[a]["mh019010"].ToString();
                    fd.mh019011  = ds.Tables[0].Rows[a]["mh019011"].ToString();
                    fd.mh019012  = ds.Tables[0].Rows[a]["mh019012"].ToString();
                    fd.mh019013  = ds.Tables[0].Rows[a]["mh019013"].ToString();
                    fd.mh019014  = ds.Tables[0].Rows[a]["mh019014"].ToString();
                    fd.mh019015  = ds.Tables[0].Rows[a]["mh019015"].ToString();
                    fd.mh019017  = ds.Tables[0].Rows[a]["mh019017"].ToString();
                    fd.mh019077  = ds.Tables[0].Rows[a]["mh019077"].ToString();
                    fd.mh019077x = ds.Tables[0].Rows[a]["mh019077x"].ToString();
                    fd.chkNone   = ds.Tables[0].Rows[a]["chkNone"].ToString();


                    fd.mh020 = ds.Tables[0].Rows[a]["mh020"].ToString();
                    fd.mh021 = ds.Tables[0].Rows[a]["mh021"].ToString();

                    fd.mh021a      = ds.Tables[0].Rows[a]["mh021a"].ToString();
                    fd.mh021TTDose = ds.Tables[0].Rows[a]["mh021TTDose"].ToString();


                    fd.mh022 = ds.Tables[0].Rows[a]["mh022"].ToString();
                    fd.mh023 = ds.Tables[0].Rows[a]["mh023"].ToString();
                    fd.mh024 = ds.Tables[0].Rows[a]["mh024"].ToString();
                    fd.mh025 = ds.Tables[0].Rows[a]["mh025"].ToString();



                    fd.mh032 = ds.Tables[0].Rows[a]["mh032"].ToString();
                    fd.mh030 = ds.Tables[0].Rows[a]["mh030"].ToString();
                    fd.mh033 = ds.Tables[0].Rows[a]["mh033"].ToString();
                    fd.mh031 = ds.Tables[0].Rows[a]["mh031"].ToString();



                    fd.mh02601 = ds.Tables[0].Rows[a]["mh02601"].ToString();
                    fd.mh02602 = ds.Tables[0].Rows[a]["mh02602"].ToString();
                    fd.mh02603 = ds.Tables[0].Rows[a]["mh02603"].ToString();
                    fd.mh02604 = ds.Tables[0].Rows[a]["mh02604"].ToString();
                    fd.mh02605 = ds.Tables[0].Rows[a]["mh02605"].ToString();
                    fd.mh02606 = ds.Tables[0].Rows[a]["mh02606"].ToString();
                    fd.mh027a  = ds.Tables[0].Rows[a]["mh027a"].ToString();

                    fd.mh02607  = ds.Tables[0].Rows[a]["mh02607"].ToString();
                    fd.mh02608  = ds.Tables[0].Rows[a]["mh02608"].ToString();
                    fd.mh02609  = ds.Tables[0].Rows[a]["mh02609"].ToString();
                    fd.mh026010 = ds.Tables[0].Rows[a]["mh026010"].ToString();
                    fd.mh026011 = ds.Tables[0].Rows[a]["mh026011"].ToString();
                    fd.mh027b   = ds.Tables[0].Rows[a]["mh027b"].ToString();

                    fd.mh026012       = ds.Tables[0].Rows[a]["mh026012"].ToString();
                    fd.mh026013       = ds.Tables[0].Rows[a]["mh026013"].ToString();
                    fd.mh026014       = ds.Tables[0].Rows[a]["mh026014"].ToString();
                    fd.mh026015       = ds.Tables[0].Rows[a]["mh026015"].ToString();
                    fd.mh026016       = ds.Tables[0].Rows[a]["mh026016"].ToString();
                    fd.mh026017       = ds.Tables[0].Rows[a]["mh026017"].ToString();
                    fd.mh026018       = ds.Tables[0].Rows[a]["mh026018"].ToString();
                    fd.mh026019       = ds.Tables[0].Rows[a]["mh026019"].ToString();
                    fd.mh026Sup       = ds.Tables[0].Rows[a]["mh026Sup"].ToString();
                    fd.chkVaccination = ds.Tables[0].Rows[a]["chkVaccination"].ToString();


                    fd.mh027 = ds.Tables[0].Rows[a]["mh027"].ToString();
                    fd.mh028 = ds.Tables[0].Rows[a]["mh028"].ToString();
                    fd.mh029 = ds.Tables[0].Rows[a]["mh029"].ToString();

                    fd.uccode    = ds.Tables[0].Rows[a]["uccode"].ToString();
                    fd.dist_id   = ds.Tables[0].Rows[a]["dist_id"].ToString();
                    fd.databy    = "desktop";
                    fd.userid    = ds.Tables[0].Rows[a]["userid"].ToString();
                    fd.entrydate = ds.Tables[0].Rows[a]["entrydate"].ToString();
                    fd.master_id = ds.Tables[0].Rows[a]["master_id"].ToString();
                    fd.ver       = ds.Tables[0].Rows[a]["ver"].ToString();


                    forms.Add(fd);
                }
            }

            catch (Exception ex)
            {
            }

            finally
            {
            }

            return(forms);
        }