示例#1
0
        /// <summary>
        /// 加入會員到訪紀錄
        /// </summary>
        /// <param name="_cost">消費金額</param>
        /// <param name="_keyword">手機號碼</param>
        #region 將使用者輸入內容存放到資料庫中(消費金額+關鍵字)
        public void SmoothDBCreate(int _cost, string _keyword)
        {
            CUSTOMER_RECORDS NewData = new CUSTOMER_RECORDS();
            DateTime         tmp_dt  = DateTime.Now;

            int  number;
            bool success = Int32.TryParse(_keyword, out number);

            if (success)
            {
                number = Convert.ToInt32(_keyword);
            }

            //判斷_keyword是否為小於10碼,若否就顯示手機號碼需小於十碼
            if (Math.Floor(Math.Log10(number) + 1) > 10)
            {
                //todo:顯示輸入手機號碼錯誤訊息
            }
            else
            {
                //todo:存入會員編號時的資料型態會出現問題
                //NewData.MEMBER_ID = int.Parse(string.Format("{0:yyyyMMdd},{1:###########}", DateTime.Now, _keyword));     //yyyymmdd+手機號碼(keyword:09xxxxxxxx)共18碼
                NewData.MEMBER_ID = number;

                NewData.DATE_Y = int.Parse(tmp_dt.Year.ToString());  //年
                NewData.DATE_M = int.Parse(tmp_dt.Month.ToString()); //月
                NewData.DATE_D = int.Parse(tmp_dt.Day.ToString());   //日

                NewData.COST    = _cost;                             //消費金額
                NewData.KEYWORD = _keyword;                          //會員固定認證號碼
                                                                     //todo:存入RECEIPT_NUM時的資料型態會出現問題
                                                                     //NewData.RECEIPT_NUM = int.Parse(string.Format("{0:yyyyMMddHHmmssfffff},{1:#####}", tmp_dt,"99999"));
                NewData.RECEIPT_NUM = NewData.DATE_Y + NewData.DATE_M + NewData.DATE_D + 567897 + int.Parse(tmp_dt.Hour.ToString()) + int.Parse(tmp_dt.Second.ToString()) + int.Parse(tmp_dt.Minute.ToString());
                NewData.MODIFY_DATE = DateTime.Now;
                NewData.MODIFY_USER = "******".ToString();
                NewData.NOTE        = "NONE".ToString();

                //新增一筆資料
                db.CUSTOMER_RECORDS.Add(NewData);

                //儲存資料庫變更
                try
                {
                    db.SaveChanges();
                }
                catch (Exception ex)
                {
                    throw;
                }
            }
        }
示例#2
0
        public void SmoothDBCreate(string _keyword)
        {
            CUSTOMER_RECORDS NewData = new CUSTOMER_RECORDS();
            DateTime         tmp_dt  = DateTime.Now;

            //NewData.NO = ;//流水號
            NewData.MEMBER_ID = int.Parse(string.Format("{0:yyyyMMdd},{1:##########}", tmp_dt, _keyword)); //yyyymmdd+手機號碼(keyword:09xxxxxxxx)共18碼

            NewData.DATE_Y = int.Parse(tmp_dt.Year.ToString());                                            //年
            NewData.DATE_M = int.Parse(tmp_dt.Month.ToString());                                           //月
            NewData.DATE_D = int.Parse(tmp_dt.Day.ToString());                                             //日

            NewData.COST        = 0;                                                                       //消費金額
            NewData.KEYWORD     = _keyword;                                                                //會員固定認證號碼
            NewData.RECEIPT_NUM = int.Parse(string.Format("{0:yyyyMMddHHmmssfffff},{1:#####}", tmp_dt, "99999"));
            NewData.MODIFY_DATE = DateTime.Now;
            NewData.MODIFY_USER = "******".ToString();

            db.CUSTOMER_RECORDS.Add(NewData); //新增一筆資料
            db.SaveChanges();                 //儲存資料庫變更
        }