Exemple #1
0
        public PartialViewResult ReturnPurchaseListPartialView(string customerName, DateTime?fromDate,
                                                               DateTime?toDate, int?userId, string userName, int?currentPageIndex)
        {
            if (string.IsNullOrEmpty(userName))
            {
                userName = string.Empty;
                userId   = 0;
            }
            if (fromDate == null)
            {
                fromDate = SystemConstant.MIN_DATE;
            }
            if (toDate == null)
            {
                toDate = SystemConstant.MAX_DATE;
            }
            var            ctx        = new SmsContext();
            var            resultList = ctx.SP_GET_RETURN_LIST(customerName, fromDate, toDate, userId, userName).Take(SystemConstant.MAX_ROWS).ToList <SP_GET_RETURN_LIST_Result>();
            int            pageSize   = SystemConstant.ROWS;
            int            pageIndex  = currentPageIndex == null ? 1 : (int)currentPageIndex;
            CustomerReturn model      = new CustomerReturn();

            model.detailReturnList = resultList.ToPagedList(pageIndex, pageSize);
            model.Count            = resultList.Count;
            ViewBag.CustomerName   = customerName;
            ViewBag.UserId         = userId;
            ViewBag.UserName       = userName;
            ViewBag.FromDate       = ((DateTime)fromDate).ToString("dd/MM/yyyy");
            ViewBag.Todate         = ((DateTime)toDate).ToString("dd/MM/yyyy");
            ctx.Dispose();
            return(PartialView("ReturnPurchaseListPartialView", model));
        }
        internal async Task <JsonResult> CreateCR(CustomerReturn newcr)
        {
            SqlConnection cn = null;

            try
            {
                cn = Connection.GetConnection();
                SqlCommand smd = new SqlCommand("cr_create", cn)
                {
                    CommandType = CommandType.StoredProcedure
                };
                smd.Parameters.AddWithValue("@type", newcr.Type);
                smd.Parameters.AddWithValue("@parent_order_no", newcr.ParentOrderNo);
                smd.Parameters.AddWithValue("@parent_invoice_no", newcr.ParentInvoiceNo);
                smd.Parameters.AddWithValue("@location_id", newcr.LocationId);
                smd.Parameters.AddWithValue("@selected_lines", ToDataTable(newcr.lines));
                smd.Parameters.Add("@jsonOutput", SqlDbType.NVarChar, -1).Direction = ParameterDirection.Output;
                await smd.ExecuteNonQueryAsync().ConfigureAwait(false);

                string json = smd.Parameters["@jsonOutput"].Value.ToString();
                smd.Dispose();
                JArray arr = JArray.Parse(json);
                return(new JsonResult(arr));
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                Connection.CloseConnection(ref cn);
            }
        }
 public async Task <JsonResult> CreateCR([FromBody] CustomerReturn newcr)
 {
     try
     {
         return(await _customerReturnLogic.CreateCR(newcr).ConfigureAwait(false));
     }
     catch (Exception ee)
     {
         return(await _customerReturnLogic.SendRespose("False", ee.Message).ConfigureAwait(false));
     }
 }