Example #1
0
        public List<Model.ReturnBookDetail> GetList(Int32 ReturnBookDetailId, Int32 ReturnBookId, Int32 OrderDetailId, int ReturnDetailStatus, int Start, int Limit)
        {
            List<Model.ReturnBookDetail> list = new List<Model.ReturnBookDetail>();

            try
            {
                SqlParameter[] p =  {
                                        new SqlParameter("@ReturnBookDetailId", SqlDbType.Int, 4),
                                        new SqlParameter("@ReturnBookId", SqlDbType.Int, 4),
                                        new SqlParameter("@OrderDetailId", SqlDbType.Int, 4),
                                        new SqlParameter("@ReturnDetailStatus", SqlDbType.Int, 4),
                                        new SqlParameter("@Start", SqlDbType.Int, 4),
                                        new SqlParameter("@Limit", SqlDbType.Int, 4)
                                    };

                p[0].Value = ReturnBookDetailId;

                p[1].Value = ReturnBookId;
                p[2].Value = OrderDetailId;
                p[3].Value = ReturnDetailStatus;
                p[4].Value = Start;
                p[5].Value = Limit;

                DataTable dt = db.ExcuteSelectReturnDataTable("ReturnBookDetail_DS", CommandType.StoredProcedure, p);

                if (null != dt && dt.Rows.Count > 0)
                {
                    foreach (DataRow dr in dt.Rows)
                    {
                        Model.ReturnBookDetail model = new Model.ReturnBookDetail();

                        model.Ind = Convert.ToInt16(dr["Ind"]);
                        model.ReturnBookDetailId = Convert.ToInt32(dr["ReturnBookDetailId"]);
                        model.ReturnBookId = Convert.ToInt32(dr["ReturnBookId"]);
                        model.Title = dr["Title"].ToString();
                        model.OrderDetailId = Convert.ToInt32(dr["OrderDetailId"]);
                        model.ReturnDetailStatus = Convert.ToInt16(dr["ReturnDetailStatus"]);
                        model.CreateTime = dr["CreateTime"].ToString();
                        model.TotalRow = Convert.ToInt32(dr["TotalRow"]);

                        list.Add(model);
                    }
                }
            }
            catch (Exception ex)
            {
                PTSLog.Error(ex);
            }

            return list;
        }
Example #2
0
        public int Update(Model.ReturnBook model)
        {
            int rowEffect = 0;

            try
            {
                string cmdText = "ReturnBook_Update";

                SqlParameter[] p =  {
                                        new SqlParameter("@ReturnBookId", SqlDbType.Int, 4),
                                        new SqlParameter("@MemberId", SqlDbType.Int, 4),
                                        new SqlParameter("@ReturnDate", SqlDbType.DateTime),
                                        new SqlParameter("@ReturnTime", SqlDbType.NVarChar, 250),
                                        new SqlParameter("@ReturnNote", SqlDbType.NText),
                                        new SqlParameter("@ReturnStatus", SqlDbType.Int, 4),
                                        new SqlParameter("@CreateBy", SqlDbType.NVarChar, 250),
                                        new SqlParameter("@ReturnAddress", SqlDbType.NVarChar, 250),
                                        new SqlParameter("@ReturnPhone", SqlDbType.NVarChar, 250)
                                    };

                p[0].Value = model.ReturnBookId;
                p[0].Direction = ParameterDirection.InputOutput;

                p[1].Value = model.MemberId;
                p[2].Value = model.ReturnDate;
                p[3].Value = model.ReturnTime;
                p[4].Value = model.ReturnNote;
                p[5].Value = model.ReturnStatus;
                p[6].Value = model.CreateBy;
                p[7].Value = model.ReturnAddress;
                p[8].Value = model.ReturnPhone;

                rowEffect = db.ExcuteCommandReturnInt(cmdText, CommandType.StoredProcedure, p);

                if (rowEffect > 0)
                {
                    Int32 ReturnBookId = (Int32)p[0].Value;

                    if (model.ReturnBookDetailList != null && model.ReturnBookDetailList.Count > 0)
                    {
                        BLL.ReturnBookDetail bll = BLL.ReturnBookDetail.Instance;

                        foreach (var item in model.ReturnBookDetailList)
                        {
                            Model.ReturnBookDetail returnmodel = new Model.ReturnBookDetail();

                            returnmodel.ReturnBookId = ReturnBookId;
                            returnmodel.OrderDetailId = item.OrderDetailId;

                            bll.Update(returnmodel);
                        }
                    }
                }

            }
            catch (Exception ex)
            {
                PTSLog.Error(ex);
            }

            return rowEffect;
        }
Example #3
0
        protected void ReturnBook(HttpContext context)
        {
            string result = string.Empty;
            int errCode = 0;

            try
            {
                string Address = context.Request["Address"];
                string Phone = context.Request["Phone"];
                string Note = context.Request["Note"];
                string MemberId = context.Request["MemberId"];
                string OrderDetailId = context.Request["OrderDetailId"];

                BLL.ReturnBook bll = BLL.ReturnBook.Instance;
                BLL.ReturnBookDetail bll_detail = BLL.ReturnBookDetail.Instance;

                Model.ReturnBook model = new Model.ReturnBook();

                model.ReturnBookId = 0;
                model.MemberId = Convert.ToInt32(MemberId);
                model.ReturnPhone = Phone;
                model.ReturnAddress = Address;
                model.ReturnNote = Note;
                model.ReturnDate = DateTime.Now.ToString();
                model.ReturnTime = string.Empty;
                model.ReturnStatus = 0;
                model.CreateBy = string.Empty;

                List<Model.ReturnBookDetail> list = new List<Model.ReturnBookDetail>();

                if (!string.IsNullOrEmpty(OrderDetailId))
                {
                    string[] arr = OrderDetailId.Split('|');

                    for (int i = 0; i < arr.Length; i++)
                    {
                        if (!string.IsNullOrEmpty(arr[i]))
                        {
                            Model.ReturnBookDetail model_detail = new Model.ReturnBookDetail();

                            model_detail.ReturnBookDetailId = 0;
                            model_detail.OrderDetailId = Convert.ToInt32(arr[i]);

                            list.Add(model_detail);

                        }
                    }
                }

                model.ReturnBookDetailList = list;

                int rows = bll.Update(model);

                result = "Đơn hàng trả sách của bạn đã gởi đến hệ thống thành công, Chúng tôi sẽ liên lạc với bạn sớm nhất có thể !";
            }
            catch (Exception ex)
            {
                errCode = 1;
                result = "Lỗi xảy ra, vui lòng thử lại !";
            }

            Hashtable hashtable = new Hashtable();
            hashtable["code"] = errCode;
            hashtable["msg"] = result;

            var json = Newtonsoft.Json.JsonConvert.SerializeObject(hashtable);
            context.Response.Write(json);
        }