Example #1
0
        public static string AddOrder(Order newOrder)
        {
            string connectionString = WebConfigurationManager.ConnectionStrings["defaultConnectionString"].ToString();
            SqlConnection sqlConn = new SqlConnection(connectionString);
            sqlConn.Open();

            string cmdString;
            SqlCommand sqlCmd = new SqlCommand();
            cmdString = "INSERT INTO [Order] (OrderID, Status, Payment, Delivery, UserID, ModiefiedDate, Name, School, Contact, Email, IdentityNo, AlreadySignedIn, ExtraInfo)" +
                "VALUES (@orderID, @status, @payment, @delivery, @userID, @modifiedDate, @name, @school, @contact, @email, @identityNo, @alreadySignedIn, @extraInfo)";
            sqlCmd = new SqlCommand(cmdString, sqlConn);
            string orderID = System.Guid.NewGuid().ToString();
            sqlCmd.Parameters.Add(new SqlParameter("orderID", orderID));
            newOrder.Status = 0;
            sqlCmd.Parameters.Add(new SqlParameter("status", newOrder.Status));
            sqlCmd.Parameters.Add(new SqlParameter("payment", newOrder.Payment));
            newOrder.Delivery = 0;
            sqlCmd.Parameters.Add(new SqlParameter("delivery", newOrder.Delivery));
            sqlCmd.Parameters.Add(new SqlParameter("userID", newOrder.UserID));
            sqlCmd.Parameters.Add(new SqlParameter("modifiedDate", DateTime.Now));
            sqlCmd.Parameters.Add(new SqlParameter("name", newOrder.Name));
            sqlCmd.Parameters.Add(new SqlParameter("school", newOrder.School));
            sqlCmd.Parameters.Add(new SqlParameter("contact", newOrder.Contact));
            sqlCmd.Parameters.Add(new SqlParameter("email", newOrder.Email));
            sqlCmd.Parameters.Add(new SqlParameter("identityNo", newOrder.IdentityNo));
            sqlCmd.Parameters.Add(new SqlParameter("alreadySignedIn", newOrder.AlreadySignedIn));
            sqlCmd.Parameters.Add(new SqlParameter("extraInfo", newOrder.ExtraInfo));
            sqlCmd.ExecuteNonQuery();

            sqlConn.Close();

            return orderID;
        }
Example #2
0
 protected void Button1_Click(object sender, EventArgs e)
 {
     Order newOrder = new Order();
     newOrder.UserID = 8;
     newOrder.Payment = 0;
     newOrder.School = "同济";
     newOrder.Name = "乙振斐";
     newOrder.Email = "*****@*****.**";
     newOrder.Contact = "13671722212";
     newOrder.IdentityNo = "111111";
     OrderService.SubmitOrder(newOrder);
 }
Example #3
0
 protected void CommmitButton_Click(object sender, EventArgs e)
 {
     Order newOrder = new Order();
     newOrder.UserID = AuthenticationService.GetUser().UserID;
     if (this.OfflinePayRadioButton.Checked)
     {
         newOrder.Payment = 0;
     }
     else if (this.AlipayRadioButton.Checked)
     {
         newOrder.Payment = 1;
     }
     newOrder.School = this.SchoolTextBox.Text;
     newOrder.Name = this.NameTextBox.Text;
     newOrder.Email = this.EmailTextBox.Text;
     newOrder.Contact = this.ContactTextBox.Text;
     newOrder.IdentityNo = this.IDNumTextBox.Text;
     OrderService.SubmitOrder(newOrder);
     Response.Redirect("/Page/Business/orderSuccess.aspx");
 }
Example #4
0
 //调用这个函数时,newOrder里填好5个基本信息,UserID,以及Payment即可。0为线下付款,1为支付宝
 public static void SubmitOrder(Order newOrder)
 {
     newOrder.SetStatusToNotPayed();
     string orderID = OrderRepository.AddOrder(newOrder);
     List<CartRecord> cartrecords = CartService.GetCartRecodByUserID(newOrder.UserID);
     foreach (CartRecord cr in cartrecords)
     {
         Item currentItem = ItemService.GetItemByItemID(cr.ItemID);
         OrderDetail od = new OrderDetail();
         od.OrderID = orderID;
         od.ItemID = cr.ItemID;
         od.Title = currentItem.Title;
         od.Price = currentItem.Price;
         od.Quantity = cr.Count;
         od.TotalPrice = od.Price * od.Quantity;
         od.ImageUrl = currentItem.ImageUrl;
         OrderRepository.AddOrderDetail(od);
     }
     CartService.DeletaCartRecordByUserID(newOrder.UserID);
 }
Example #5
0
        protected void orderDetailSubmitButton_Click(object sender, EventArgs e)
        {
            Order newOrder = new Order();
            newOrder.UserID = AuthenticationService.GetUser().UserID;
            if (this.OfflinePayRadioButton.Checked)
            {
                newOrder.Payment = 0;
                newOrder.ExtraInfo = "";
            }
            else if (this.AlipayRadioButton.Checked)
            {
                newOrder.Payment = 1;
                newOrder.ExtraInfo = "支付宝帐号=" + AlipayAccountTextBox.Text + ",户主名称=" + AlipayAccountOwnerNameTextBox.Text;
            }
            else if (this.PhonePayRadioButton.Checked)
            {
                newOrder.Payment = 2;
                newOrder.ExtraInfo = "手机号码=" + PhoneNoTextBox.Text;
            }
            else if (this.NetworkedGameRadioButton.Checked)
            {
                newOrder.Payment = 3;
                newOrder.ExtraInfo = "网游名称=" + GameNameTextBox.Text + ",网游帐号=" + GameAccountTextBox.Text + ",其他信息=" + GameOtherInfoTextBox.Text;
            }
            else if (this.BankcardRadioButton.Checked)
            {
                newOrder.Payment = 4;
                newOrder.ExtraInfo = "银行卡帐号=" + BankcardAccountTextBox.Text + ",户主名称=" + BankcardAccountOwnerNameTextBox.Text;
            }

            newOrder.Name = this.NameTextBox.Text;
            newOrder.School = this.SchoolTextBox.Text;
            newOrder.Contact = this.ContactTextBox.Text;
            newOrder.IdentityNo = this.IDNumTextBox.Text;
            newOrder.Email = this.EmailTextBox.Text == "邮箱(选填)" ? "" : this.EmailTextBox.Text;
            newOrder.AlreadySignedIn = this.IsRegistCourseCheckBox.Checked ? 1 : 0;
            OrderService.SubmitOrder(newOrder);
            Response.Redirect("/Page/V2/Help/orderSubmitSuccess.aspx");
        }
Example #6
0
        public static Order FindOrderByOrderID(string orderID)
        {
            Order result = new Order();

            string connectionString = WebConfigurationManager.ConnectionStrings["defaultConnectionString"].ToString();
            SqlConnection sqlConn = new SqlConnection(connectionString);
            sqlConn.Open();

            string cmdString = "SELECT * FROM [Order] WHERE OrderID = @orderID";
            SqlCommand sqlCmd = new SqlCommand(cmdString, sqlConn);
            sqlCmd.Parameters.Add(new SqlParameter("orderID", orderID));

            SqlDataReader sqlDataReader = sqlCmd.ExecuteReader();
            if (sqlDataReader.HasRows)
            {
                while (sqlDataReader.Read())
                {
                    FillOrder(sqlDataReader, result);
                }
                sqlDataReader.Close();
            }

            return result;
        }
        private Panel renderMyOrderItem(Order order)
        {
            Panel myOrderItemContainer = new Panel();
            myOrderItemContainer.CssClass = "myOrderItemContainer";
            Panel myOrderItemImageContainer = new Panel();
            myOrderItemImageContainer.CssClass = "myOrderItemImageContainer";
            Panel myOrderItemDetailContainer = new Panel();
            myOrderItemDetailContainer.CssClass = "myOrderItemDetailContainer";
            Panel myOrderItemStatusContainer = new Panel();
            myOrderItemStatusContainer.CssClass = "myOrderItemStatusContainer";

            Image image = new Image();
            //使用默认图片
            image.ImageUrl = "~/Image/ItemImage/default.jpg";
            myOrderItemImageContainer.Controls.Add(image);

            Panel panel = new Panel();
            Label label = new Label();
            label.Text = "订单号:" + order.OrderSerialNumber.ToString();
            panel.Controls.Add(label);
            myOrderItemDetailContainer.Controls.Add(panel);

            panel = new Panel();
            label = new Label();
            label.Text = "下单日期:" + order.ModiefiedDate.ToShortDateString();
            panel.Controls.Add(label);
            myOrderItemDetailContainer.Controls.Add(panel);

            panel = new Panel();
            label = new Label();
            //使用默认付款方式
            if (order.Payment == 0)
            {
                label.Text = "付款方式:" + "线下支付";
            }
            else if (order.Payment == 1)
            {
                label.Text = "付款方式:" + "支付宝付款";
            }
            panel.Controls.Add(label);
            myOrderItemDetailContainer.Controls.Add(panel);

            panel = new Panel();
            label = new Label();
            Decimal orderPrice = OrderService.GetOrderPrice(order.OrderID);
            label.Text = "金额:" + orderPrice.ToString();
            panel.Controls.Add(label);
            myOrderItemDetailContainer.Controls.Add(panel);

            Button button = new Button();
            //使用默认订单状态
            if (order.Status == 0)
            {
                button.Text = "未付款";
            }
            else if (order.Status == 1)
            {
                button.Text = "已付款";
            }
            else if (order.Status == 2)
            {
                button.Text = "已完成";
            }
            else if (order.Status == 3)
            {
                button.Text = "已作废";
            }
            button.CssClass = "myOrderItemStatusButton";
            button.Enabled = false;
            myOrderItemStatusContainer.Controls.Add(button);

            myOrderItemContainer.Controls.Add(myOrderItemImageContainer);
            myOrderItemContainer.Controls.Add(myOrderItemDetailContainer);
            myOrderItemContainer.Controls.Add(myOrderItemStatusContainer);
            return myOrderItemContainer;
        }
Example #8
0
 static void FillOrder(SqlDataReader sqlDataReader, Order newOrder)
 {
     newOrder.OrderSerialNumber = (int)sqlDataReader["OrderSerialNumber"];
     newOrder.OrderID = (string)sqlDataReader["OrderID"];
     newOrder.Status = (int)sqlDataReader["Status"];
     newOrder.Payment = (int)sqlDataReader["Payment"];
     newOrder.Delivery = (int)sqlDataReader["Delivery"];
     newOrder.UserID = (int)sqlDataReader["UserID"];
     newOrder.ModiefiedDate = (DateTime)sqlDataReader["ModiefiedDate"];
     newOrder.Name = (string)sqlDataReader["Name"];
     newOrder.School = (string)sqlDataReader["School"];
     newOrder.Contact = (string)sqlDataReader["Contact"];
     newOrder.Email = (string)sqlDataReader["Email"];
     newOrder.IdentityNo = (string)sqlDataReader["IdentityNo"];
     newOrder.AlreadySignedIn = (int)sqlDataReader["AlreadySignedIn"];
     newOrder.ExtraInfo = sqlDataReader["ExtraInfo"] == null ? "" : (string)sqlDataReader["ExtraInfo"];
 }
Example #9
0
        public static List<Order> FindOrdersByUserID(int UserID)
        {
            List<Order> result = new List<Order>();

            string connectionString = WebConfigurationManager.ConnectionStrings["defaultConnectionString"].ToString();
            SqlConnection sqlConn = new SqlConnection(connectionString);
            sqlConn.Open();

            string cmdString = "SELECT * FROM [Order] WHERE UserID = @userID";
            SqlCommand sqlCmd = new SqlCommand(cmdString, sqlConn);
            sqlCmd.Parameters.Add(new SqlParameter("userID", UserID));

            SqlDataReader sqlDataReader = sqlCmd.ExecuteReader();
            if (sqlDataReader.HasRows)
            {
                while (sqlDataReader.Read())
                {
                    Order newOrder = new Order();
                    FillOrder(sqlDataReader, newOrder);
                    result.Add(newOrder);
                }
                sqlDataReader.Close();
            }

            return result;
        }
Example #10
0
        public static List<Order> FindOrdersByStatusAndDate(int status, int day)
        {
            List<Order> result = new List<Order>();

            string connectionString = WebConfigurationManager.ConnectionStrings["defaultConnectionString"].ToString();
            SqlConnection sqlConn = new SqlConnection(connectionString);
            sqlConn.Open();

            string cmdString = "SELECT * FROM [Order] WHERE Status=@status AND DATEDIFF(day, ModiefiedDate, GETDATE()) <= @day";
            SqlCommand sqlCmd = new SqlCommand(cmdString, sqlConn);
            sqlCmd.Parameters.Add(new SqlParameter("status", status));
            sqlCmd.Parameters.Add(new SqlParameter("day", day));

            SqlDataReader sqlDataReader = sqlCmd.ExecuteReader();
            if (sqlDataReader.HasRows)
            {
                while (sqlDataReader.Read())
                {
                    Order newOrder = new Order();
                    FillOrder(sqlDataReader, newOrder);
                    result.Add(newOrder);
                }
                sqlDataReader.Close();
            }

            return result;
        }
Example #11
0
        public string SubmitOrder(string username, string password, string school, string name, string email, string contact, string identityNo, int alreadySignedIn)
        {
            bool success = UserService.VerifyPassword(username, password);
            if (!success) return JSONService.JsonSerializer(success);

            Order newOrder = new Order();
            newOrder.UserID = UserService.GetUserByUsername(username).UserID;
            newOrder.Payment = 0;
            newOrder.Delivery = 0;
            newOrder.Name = name;
            newOrder.Email = email;
            newOrder.Contact = contact;
            newOrder.IdentityNo = identityNo;
            newOrder.AlreadySignedIn = alreadySignedIn;
            OrderService.SubmitOrder(newOrder);
            CartService.DeletaCartRecordByUserID(newOrder.UserID);
            return JSONService.JsonSerializer(success);
        }