Exemplo n.º 1
0
        public void SaveDetail(int seqs, int seqe)
        {
            StringBuilder sb = new StringBuilder();

            if (SurveyData != null && SurveyData.Rows.Count > 0)
            {
                YPSCS.Framework.Data.SQLiteData dc = new Framework.Data.SQLiteData();
                dc.Parameter.Clear();
                dc.Parameter.Add("svid", DbType.String).Value = ID;
                sb.Append("DELETE FROM prd_ansdetail WHERE svid=:svid AND seq between '" + seqs.ToString() + "' AND '" + seqe.ToString() + "';");
                for (int x = 0; x < SurveyData.Rows.Count; x++)
                {
                    sb.Append("INSERT INTO prd_ansdetail (svid,seq,ans) VALUES (:svid,:seq" + x.ToString() + ",:ans" + x.ToString() + ");");
                    dc.Parameter.Add("seq" + x.ToString(), DbType.Int32).Value  = int.Parse(SurveyData.Rows[x]["seq"].ToString());
                    dc.Parameter.Add("ans" + x.ToString(), DbType.String).Value = SurveyData.Rows[x]["ans"].ToString();
                }
                sb.Append("UPDATE prd_ans set modifydate=datetime('now','+8 Hours') WHERE id='" + ID + "';");

                dc.CommandText = sb.ToString();

                dc.Connection.Open();
                dc.ExecuteNonQuery();
                dc.Connection.Close();
                dc.Connection.Dispose();
            }
        }
Exemplo n.º 2
0
        public void Create()
        {
            if (!String.IsNullOrEmpty(SurveyCode) && !String.IsNullOrEmpty(Email))
            {
                YPSCS.Framework.Data.SQLiteData dc = new Framework.Data.SQLiteData();
                dc.Parameter.Clear();
                string sql = "DELETE FROM prd_ans WHERE id=:svid;";

                if (!String.IsNullOrEmpty(ID))
                {
                    dc.Parameter.Add("svid", DbType.String).Value = ID;
                }
                else
                {
                    dc.Parameter.Add("svid", DbType.String).Value = DBNull.Value;
                }
                dc.CommandText = sql;
                dc.Connection.Open();
                dc.ExecuteNonQuery();


                sql = "INSERT INTO prd_ans (id,svcode,email,company,department,name,people,tel,title,modifydate,language) VALUES (:svid,:svcode,:email,:company,:department,:name,:people,:tel,:title,datetime('now','+8 Hours'),:language)";
                if (!String.IsNullOrEmpty(SurveyCode))
                {
                    dc.Parameter.Add("svcode", DbType.String).Value = SurveyCode;
                }
                else
                {
                    dc.Parameter.Add("svcode", DbType.String).Value = DBNull.Value;
                }
                if (!String.IsNullOrEmpty(Email))
                {
                    dc.Parameter.Add("email", DbType.String).Value = Email;
                }
                else
                {
                    dc.Parameter.Add("email", DbType.String).Value = DBNull.Value;
                }
                if (!String.IsNullOrEmpty(Company))
                {
                    dc.Parameter.Add("company", DbType.String).Value = Company;
                }
                else
                {
                    dc.Parameter.Add("company", DbType.String).Value = DBNull.Value;
                }
                if (!String.IsNullOrEmpty(Department))
                {
                    dc.Parameter.Add("department", DbType.String).Value = Department;
                }
                else
                {
                    dc.Parameter.Add("department", DbType.String).Value = DBNull.Value;
                }
                if (!String.IsNullOrEmpty(Name))
                {
                    dc.Parameter.Add("name", DbType.String).Value = Name;
                }
                else
                {
                    dc.Parameter.Add("name", DbType.String).Value = DBNull.Value;
                }
                if (!String.IsNullOrEmpty(People))
                {
                    dc.Parameter.Add("people", DbType.Int32).Value = int.Parse(People.Trim());
                }
                else
                {
                    dc.Parameter.Add("people", DbType.Int32).Value = DBNull.Value;
                }
                if (!String.IsNullOrEmpty(Tel))
                {
                    dc.Parameter.Add("tel", DbType.String).Value = Tel;
                }
                else
                {
                    dc.Parameter.Add("tel", DbType.String).Value = DBNull.Value;
                }
                if (!String.IsNullOrEmpty(Title))
                {
                    dc.Parameter.Add("title", DbType.String).Value = Title;
                }
                else
                {
                    dc.Parameter.Add("title", DbType.String).Value = DBNull.Value;
                }
                if (!String.IsNullOrEmpty(Language))
                {
                    dc.Parameter.Add("language", DbType.String).Value = Language;
                }
                else
                {
                    dc.Parameter.Add("language", DbType.String).Value = DBNull.Value;
                }
                dc.CommandText = sql;

                dc.ExecuteNonQuery();
                dc.Connection.Close();
                dc.Connection.Dispose();
            }
        }