Example #1
0
        public void updateLocalMobil(string acccount, string mobil, out Error error)
        {
            error = null;
            SqlParameter sqlParam;

            IList <SqlParameter> paraList = new System.Collections.Generic.List <SqlParameter>();
            string strSQL = "update consumer_member set CM007=@CM007 where CM002=@CM002;";

            THC_Library.DataBase.DataBaseControl dbCtl = new THC_Library.DataBase.DataBaseControl();
            try
            {
                sqlParam = new SqlParameter("@CM007", mobil);
                if (mobil == null)
                {
                    sqlParam.Value = DBNull.Value;
                }
                else
                {
                    sqlParam.Value = mobil;
                }
                paraList.Add(sqlParam);
                sqlParam = new SqlParameter("@CM002", acccount);
                paraList.Add(sqlParam);

                dbCtl.Open();
                dbCtl.ExecuteScalar(strSQL, paraList);
            }
            catch (SqlException sqlEx)
            {
                error = new Error();
                if (sqlEx.Number == 2601)
                {
                    error.Number       = 101;
                    error.ErrorMessage = "帳號已註冊";
                }
                else
                {
                    error.Number       = 100;
                    error.ErrorMessage = "系統錯誤";
                }
            }
            catch (Exception ex)
            {
                error              = new Error();
                error.Number       = 100;
                error.ErrorMessage = "系統錯誤";
            }
            finally
            {
                dbCtl.Close();
            }
        }
Example #2
0
        public void updateLocalAccount(string acccount, string mobil, string iid, string addr, out Error error)
        {
            /*
             * CM001	Int	PK		1.0
             * CM002	varchar(50)	會員帳號	唯一 mail     1.0
             * CM003	varchar (50)	FB帳號		1.0
             * CM004	varchar (50)	Line帳號		1.0
             * CM005	varchar (50)	Google帳號		1.0
             * CM006	nvarchar (20)	會員姓名		1.0
             * CM007	varchar(10)	手機號碼		1.0
             * CM008	nvarchar(200)	地址		1.0
             * CM009	varchar(10)	身分證號		1.0
             * CM010	char(1)	性別	‘’未填 0 女 1 男 2 彩虹   1.0
             * CM011	char(1)	年齡	1 10-19 2 20-29 ……	1.0
             *
             */

            error = null;
            SqlParameter sqlParam;

            IList <SqlParameter> paraList = new System.Collections.Generic.List <SqlParameter>();
            string strSQL = "update consumer_member set CM007=@CM007,CM008=@CM008,CM009=@CM009 " +
                            "where CM002=@CM002;";

            THC_Library.DataBase.DataBaseControl dbCtl = new THC_Library.DataBase.DataBaseControl();
            try
            {
                sqlParam = new SqlParameter("@CM007", mobil);
                if (mobil == null)
                {
                    sqlParam.Value = DBNull.Value;
                }
                else
                {
                    sqlParam.Value = mobil;
                }
                paraList.Add(sqlParam);
                sqlParam = new SqlParameter("@CM008", SqlDbType.NVarChar);
                if (addr == null)
                {
                    sqlParam.Value = DBNull.Value;
                }
                else
                {
                    sqlParam.Value = addr;
                }
                paraList.Add(sqlParam);
                sqlParam = new SqlParameter("@CM009", SqlDbType.VarChar);
                if (iid == null)
                {
                    sqlParam.Value = DBNull.Value;
                }
                else
                {
                    sqlParam.Value = iid;
                }
                paraList.Add(sqlParam);
                sqlParam = new SqlParameter("@CM002", acccount);
                paraList.Add(sqlParam);

                dbCtl.Open();
                dbCtl.ExecuteScalar(strSQL, paraList);
            }
            catch (SqlException sqlEx)
            {
                error = new Error();
                if (sqlEx.Number == 2601)
                {
                    error.Number       = 101;
                    error.ErrorMessage = "帳號已註冊";
                }
                else
                {
                    error.Number       = 100;
                    error.ErrorMessage = "系統錯誤";
                }
            }
            catch (Exception ex)
            {
                error              = new Error();
                error.Number       = 100;
                error.ErrorMessage = "系統錯誤";
            }
            finally
            {
                dbCtl.Close();
            }
        }