Esempio n. 1
0
        /// <summary>
        /// 新增資料
        /// </summary>
        public int Add(Models.MReceipt mod)
        {
            SqlCommand    cmd    = new SqlCommand();
            StringBuilder sbTSQL = new StringBuilder();

            sbTSQL.AppendLine("insert into [TB_Receipt] ([TWYear],[MemberID],[MemberType],[ReceiptType]");
            sbTSQL.AppendLine(",[Fee],[ReceivedFromAppend],[Remark],[CreateUser],[CreateDate],[CancelUser]");
            sbTSQL.AppendLine(",[CancelDate],[Enable])");
            sbTSQL.AppendLine("values (@TWYear,@MemberID,@MemberType,@ReceiptType");
            sbTSQL.AppendLine(",@Fee,@ReceivedFromAppend,@Remark,@CreateUser,@CreateDate,@CancelUser");
            sbTSQL.AppendLine(",@CancelDate,@Enable)");
            sbTSQL.AppendLine(";select @@identity;");
            cmd.CommandType = CommandType.Text;
            cmd.Parameters.Add("@TWYear", SqlDbType.Int).Value           = mod.TWYear;
            cmd.Parameters.Add("@MemberID", SqlDbType.NVarChar).Value    = mod.MemberID;
            cmd.Parameters.Add("@MemberType", SqlDbType.NVarChar).Value  = mod.MemberType;
            cmd.Parameters.Add("@ReceiptType", SqlDbType.NVarChar).Value = mod.ReceiptType;
            cmd.Parameters.Add("@Fee", SqlDbType.Int).Value = mod.Fee;
            cmd.Parameters.Add("@ReceivedFromAppend", SqlDbType.NVarChar).Value = mod.ReceivedFromAppend;
            cmd.Parameters.Add("@Remark", SqlDbType.NVarChar).Value             = mod.Remark;
            cmd.Parameters.Add("@CreateUser", SqlDbType.NVarChar).Value         = mod.CreateUser;
            cmd.Parameters.Add("@CreateDate", SqlDbType.DateTime).Value         = mod.CreateDate;
            cmd.Parameters.Add("@CancelUser", SqlDbType.NVarChar).Value         = SQLUtil.CheckDBValue(mod.CancelUser);
            cmd.Parameters.Add("@CancelDate", SqlDbType.DateTime).Value         = SQLUtil.CheckDBValue(mod.CancelDate);
            cmd.Parameters.Add("@Enable", SqlDbType.Bit).Value = mod.Enable;
            cmd.CommandText = sbTSQL.ToString();
            object obj   = SQLUtil.ExecuteScalar(cmd);
            int    intID = 0;

            if (obj != null && int.TryParse(obj.ToString(), out intID))
            {
                mod.ReceiptID = intID;
            }
            return(intID);
        }
Esempio n. 2
0
 /// <summary>
 /// 實體物件取得DataRow資料
 /// </summary>
 private Models.MReceipt SetModel(DataRow dr)
 {
     Models.MReceipt mod = new Models.MReceipt();
     mod.ReceiptID          = int.Parse(dr["ReceiptID"].ToString());
     mod.TWYear             = int.Parse(dr["TWYear"].ToString());
     mod.MemberID           = dr["MemberID"].ToString();
     mod.MemberType         = dr["MemberType"].ToString();
     mod.ReceiptType        = dr["ReceiptType"].ToString();
     mod.Fee                = int.Parse(dr["Fee"].ToString());
     mod.ReceivedFromAppend = dr["ReceivedFromAppend"].ToString();
     mod.Remark             = dr["Remark"].ToString();
     mod.CreateUser         = dr["CreateUser"].ToString();
     mod.CreateDate         = DateTime.Parse(dr["CreateDate"].ToString());
     mod.CancelUser         = SQLUtil.GetString(dr["CancelUser"]);
     mod.CancelDate         = SQLUtil.GetDateTime(dr["CancelDate"]);
     mod.Enable             = bool.Parse(dr["Enable"].ToString());
     return(mod);
 }
Esempio n. 3
0
        /// <summary>
        /// 取得單筆資料
        /// <summary>
        public Models.MReceipt GetModel(int intReceiptID)
        {
            SqlCommand cmd = new SqlCommand("STP_ReceiptGetByPK");

            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.Add("@ReceiptID", SqlDbType.Int).Value = intReceiptID;
            SqlDataReader dr        = SQLUtil.QueryDR(cmd);
            bool          isHasRows = dr.HasRows;

            Models.MReceipt mod = SetModel(dr);
            dr.Close();
            if (isHasRows)
            {
                return(mod);
            }
            else
            {
                return(null);
            }
        }
Esempio n. 4
0
 /// <summary>
 /// 新增資料
 /// </summary>
 public int Add(Models.MReceipt mod)
 {
     return(new DAL.DReceipt().Add(mod));
 }