public IHttpActionResult PostCourierInfo(CourierInfo courierInfo)
 {
     courierInfo.Time = DateTime.Now;
     db.CourierInfoes.Add(courierInfo);
     db.SaveChanges();
     return(CreatedAtRoute("DefaultApi", new { id = courierInfo.CourierId }, courierInfo));
 }
 protected void EgvDeliverItem_RowDataBound(object sender, GridViewRowEventArgs e)
 {
     if (e.Row.RowType == DataControlRowType.DataRow)
     {
         DeliverItemInfo dataItem = e.Row.DataItem as DeliverItemInfo;
         e.Row.Cells[1].Text = (dataItem.DeliverDirection == 1) ? "发货" : "<span style='color:#F00'>退货</span>";
         e.Row.Cells[6].Text = dataItem.Received ? "<span style='color:#F00'><strong>√</strong></span>" : "";
         Literal literal = (Literal)e.Row.FindControl("LitExpressCompony");
         if (dataItem.CourierId > 0)
         {
             literal.Text = this.GetExpressCompony(dataItem.CourierId);
         }
         if ((dataItem.DeliverDirection == 1) && !dataItem.Received)
         {
             e.Row.Cells[8].Enabled = true;
         }
         else
         {
             e.Row.Cells[8].Text = "";
         }
         Literal literal2 = (Literal)e.Row.FindControl("LitExpressNumber");
         literal2.Text = dataItem.ExpressNumber;
         Literal     literal3 = (Literal)e.Row.FindControl("LitExpressState");
         CourierInfo courier  = Courier.GetCourier(dataItem.CourierId);
         if (!string.IsNullOrEmpty(courier.SearchUrl))
         {
             literal3.Text = "<a href=" + courier.SearchUrl.Replace("{$ExpressNumber}", dataItem.ExpressNumber) + " Target=\"_Blank\">查看</a>";
         }
     }
 }
Beispiel #3
0
        public List <SqlParameter> SetValuesInCourierInfo(CourierInfo CourierInfo)
        {
            List <SqlParameter> sqlParam = new List <SqlParameter>();

            if (CourierInfo.Id != 0)
            {
                sqlParam.Add(new SqlParameter("@Id", CourierInfo.Id));
            }
            else
            {
                sqlParam.Add(new SqlParameter("@CreatedBy", CourierInfo.CreatedBy));
            }

            sqlParam.Add(new SqlParameter("@CourierId", CourierInfo.CourierId));

            sqlParam.Add(new SqlParameter("@CourierName", CourierInfo.CourierName));

            sqlParam.Add(new SqlParameter("@ServedPincode", CourierInfo.ServedPincode));

            sqlParam.Add(new SqlParameter("@IsActive", CourierInfo.IsActive));

            sqlParam.Add(new SqlParameter("UpdatedBy", CourierInfo.UpdatedBy));

            return(sqlParam);
        }
        public ActionResult DeleteConfirmed(int id)
        {
            CourierInfo courierInfo = db.CourierInfo.Find(id);

            db.CourierInfo.Remove(courierInfo);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
        public IHttpActionResult DeleteCourierInfo(int id)
        {
            CourierInfo courierInfo = db.CourierInfoes.Find(id);

            if (courierInfo == null)
            {
                return(NotFound());
            }
            db.CourierInfoes.Remove(courierInfo);
            db.SaveChanges();
            return(Ok(courierInfo));
        }
Beispiel #6
0
        public static CourierInfo GetItemInfoFromrdataReader(NullableDataReader dataReader)
        {
            CourierInfo info = new CourierInfo();

            info.CourierId = dataReader.GetInt32("CourierId");
            info.ShortName = dataReader.GetString("ShortName");
            info.FullName  = dataReader.GetString("FullName");
            info.Address   = dataReader.GetString("Address");
            info.Telephone = dataReader.GetString("Telephone");
            info.Contacter = dataReader.GetString("Contacter");
            info.SearchUrl = dataReader.GetString("SearchUrl");
            return(info);
        }
Beispiel #7
0
        private static Parameters GetParameters(CourierInfo courier)
        {
            Parameters parameters = new Parameters();

            parameters.AddInParameter("@CourierId", DbType.Int32, courier.CourierId);
            parameters.AddInParameter("@ShortName", DbType.String, courier.ShortName);
            parameters.AddInParameter("@FullName", DbType.String, courier.FullName);
            parameters.AddInParameter("@Address", DbType.String, courier.Address);
            parameters.AddInParameter("@Telephone", DbType.String, courier.Telephone);
            parameters.AddInParameter("@Contacter", DbType.String, courier.Contacter);
            parameters.AddInParameter("@SearchUrl", DbType.String, courier.SearchUrl);
            return(parameters);
        }
Beispiel #8
0
        public CourierInfo Get_Courier_By_Id(int CourierId)
        {
            List <SqlParameter> sqlParams   = new List <SqlParameter>();
            CourierInfo         courierInfo = new CourierInfo();

            sqlParams.Add(new SqlParameter("@CourierId", CourierId));
            DataTable dt = _sqlHelper.ExecuteDataTable(sqlParams, StoredProcedureEnum.sp_GetCourierById.ToString(), CommandType.StoredProcedure);

            foreach (DataRow dr in dt.Rows)
            {
                courierInfo = Get_Courier_Values(dr);
            }
            return(courierInfo);
        }
        // GET: CourierInfoes/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            CourierInfo courierInfo = db.CourierInfo.Find(id);

            if (courierInfo == null)
            {
                return(HttpNotFound());
            }
            return(View(courierInfo));
        }
Beispiel #10
0
        private CourierInfo Get_Courier_Values(DataRow dr)
        {
            CourierInfo courierInfo = new CourierInfo();

            courierInfo.Id            = Convert.ToInt32(dr["Id"]);
            courierInfo.CourierId     = Convert.ToString(dr["CourierId"]);
            courierInfo.CourierName   = Convert.ToString(dr["CourierName"]);
            courierInfo.ServedPincode = Convert.ToString(dr["ServedPincode"]);
            courierInfo.IsActive      = Convert.ToBoolean(dr["Active"]);
            courierInfo.CreatedBy     = Convert.ToInt32(dr["CreatedBy"]);
            courierInfo.CreatedDate   = Convert.ToDateTime(dr["CreatedOn"]);
            courierInfo.UpdatedBy     = Convert.ToInt32(dr["UpdatedBy"]);
            courierInfo.UpdatedDate   = Convert.ToDateTime(dr["UpdatedOn"]);
            return(courierInfo);
        }
        public CourierViewModel()
        {
            CourierInfo = new CourierInfo();

            FriendlyMessage = new List <FriendlyMessage>();

            CourierList = new List <CourierInfo>();

            Pager = new PaginationInfo();

            AddressViewModelList = new AddressViewModel();

            ContactViewModelList = new ContactViewModel();

            AddressViewModelList.Address.AddressFor = AddressFor.Warehouse.ToString();

            ContactViewModelList.ContactDetails.ContactFor = AddressFor.Warehouse.ToString();
        }
 public ActionResult Edit([Bind(Include = "Id,Name")] CourierInfo courierInfo)
 {
     if (ModelState.IsValid)
     {
         if (db.CourierInfo.Where(x => x.Name.ToLower() == courierInfo.Name.ToLower() && x.Id != courierInfo.Id).Count() > 0)
         {
             Danger("Name exists! Try different.", true);
         }
         else
         {
             courierInfo.OpBy            = 1;
             courierInfo.OpOn            = DateTime.Now;
             db.Entry(courierInfo).State = EntityState.Modified;
             db.SaveChanges();
             return(RedirectToAction("Index"));
         }
     }
     return(View(courierInfo));
 }
        public IHttpActionResult PutCourierInfo(CourierInfo courierInfo)
        {
            if (!CourierInfoExists(courierInfo.CourierId))
            {
                return(PostCourierInfo(courierInfo));
            }
            CourierInfo currentCourierInfo = db.CourierInfoes.Find(courierInfo.CourierId);

            currentCourierInfo.Time     = DateTime.Now;
            currentCourierInfo.Latitude = courierInfo.Latitude == 0 ?
                                          currentCourierInfo.Latitude :
                                          courierInfo.Latitude;
            currentCourierInfo.Longitude = courierInfo.Longitude == 0 ?
                                           currentCourierInfo.Longitude :
                                           courierInfo.Longitude;
            currentCourierInfo.Speed  = courierInfo.Speed;
            currentCourierInfo.Status = courierInfo.Status == null ?
                                        currentCourierInfo.Status :
                                        courierInfo.Status;
            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!CourierInfoExists(courierInfo.CourierId))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }
            return(StatusCode(HttpStatusCode.NoContent));
        }
Beispiel #14
0
        public bool Add(CourierInfo courier)
        {
            Parameters cmdParams = GetParameters(courier);

            return(DBHelper.ExecuteSql("INSERT PE_Courier(ShortName, FullName, Address, Telephone, Contacter, SearchUrl) VALUES (@ShortName, @FullName, @Address, @Telephone,@Contacter, @SearchUrl)", cmdParams));
        }
Beispiel #15
0
 public static bool Add(CourierInfo courier)
 {
     return(dal.Add(courier));
 }
Beispiel #16
0
 public int Insert(CourierInfo CourierInfo)
 {
     return(Convert.ToInt32(_sqlHelper.ExecuteScalerObj(SetValuesInCourierInfo(CourierInfo), StoredProcedureEnum.sp_Insert_Courier.ToString(), CommandType.StoredProcedure)));
 }
 public void Update_Courier(CourierInfo courierInfo)
 {
     _courierRepo.Update(courierInfo);
 }
 public int Insert_Courier(CourierInfo courierInfo)
 {
     return(_courierRepo.Insert(courierInfo));
 }
        /// <summary>
        /// Used for parsing textual data
        /// </summary>
        /// <param name="lines">Lines in the textual input file</param>
        /// <returns>Information regarding the input file</returns>
        public ShipmentsData Parse(string[] lines)
        {
            List <CourierInfo> couriers       = new List <CourierInfo>();
            CourierInfo        currentCourier = new CourierInfo();

            for (int i = 0; i < lines.Length; i++)
            {
                if (lines[i].Length == 0)
                {
                    logger.Debug("Empty line found.", i, 0);
                    continue;
                }

                if (characterToSkip.Contains(lines[i][0]))
                {
                    lines[i] = lines[i].TrimStart(characterToSkip);
                    if (lines[i].Length == 0)
                    {
                        continue;
                    }
                }

                if (linesToIgnore.Contains(lines[i][0]))
                {
                    logger.Debug("Empty line found.", i, 0);
                    continue;
                }

                //Manage courier name
                if (courier.IsMatch(lines[i]))
                {
                    if (currentCourier.Name != null)
                    {
                        string msg = string.Format("Adding info for {0}. {1} shipments.", currentCourier.Name, currentCourier.Shipments.Count);
                        logger.Debug(msg, i, 0);
                        couriers.Add(currentCourier);
                        currentCourier = new CourierInfo();
                    }

                    Match regExMatch = courier.Match(lines[i]);
                    currentCourier.ID   = int.Parse(regExMatch.Groups[1].Value.Trim());
                    currentCourier.Name = regExMatch.Groups[2].Value.Trim();
                    logger.Debug(string.Format("Found courier with name: {0}", currentCourier.Name), i, 0);
                }
                // Manage header information
                else if (i + 1 < lines.Length && lines[i + 1].Length > 0 && lines[i + 1][0] == '-')
                {
                    if (tableInfo == null)
                    {
                        logger.Debug("Meta-info: found.", i, 0);
                        tableInfo = HandleTableInfo(lines[i], lines[i + 1]);
                        logger.Debug("Meta-info: added successfully.", i, 0);
                    }
                }
                // Manage shipment line
                else
                {
                    if (currentCourier.Name != null && tableInfo != null)
                    {
                        currentCourier.Shipments.Add(HandleShipmentRecord(lines[i], tableInfo));
                    }
                }
            }

            // Managing last courier
            if (currentCourier.Name != null)
            {
                string msg = string.Format("Adding info for {0}. {1} shipments.", currentCourier.Name, currentCourier.Shipments.Count);
                logger.Debug(msg, lines.Length, 0);
                couriers.Add(currentCourier);
            }

            if (tableInfo == null)
            {
                throw new ParsingException("Formato del file incorretto. Header non trovato. ", null);
            }

            if (couriers.Count == 0)
            {
                throw new ParsingException("Formato del file incorretto. Nessun corriere trovato. ", null);
            }

            return(new ShipmentsData()
            {
                Shipments = couriers, MetaInformation = tableInfo, Date = date
            });
        }
Beispiel #20
0
 public static bool Update(CourierInfo courier)
 {
     return(dal.Update(courier));
 }
Beispiel #21
0
        public bool Update(CourierInfo courier)
        {
            Parameters cmdParams = GetParameters(courier);

            return(DBHelper.ExecuteSql("UPDATE PE_Courier SET ShortName = @ShortName, FullName = @FullName, Address = @Address, Telephone = @Telephone, Contacter = @Contacter, SearchUrl = @SearchUrl WHERE CourierId = @CourierId", cmdParams));
        }
Beispiel #22
0
 public void Update(CourierInfo CourierInfo)
 {
     _sqlHelper.ExecuteNonQuery(SetValuesInCourierInfo(CourierInfo), StoredProcedureEnum.sp_Update_Courier.ToString(), CommandType.StoredProcedure);
 }