protected override void OnPreRender(EventArgs e) { base.OnPreRender(e); OrderInfo info = OrderDB.GetInfo(_orderid); if (info == null) { return; } lblID.Text = info.Order_ID.ToString(); lblDateTime.Text = ConvertUtility.ToDateTime(info.Order_CreateDate).ToString("dd/MM/yyyy HH:mm"); lnkFullname.Text = info.Order_Fullname; lnkFullname.NavigateUrl = AppEnv.ADMIN_CMD + "memberupdate&memberid=" + info.Member_ID; lblEmail.Text = info.Order_Email; lblPhone.Text = info.Order_Tel; lblAddress.Text = info.Order_Address.Replace("\n", "<br>"); lblDistrict.Text = info.Order_District; lblCity.Text = info.Order_City; lblContent.Text = info.Order_Note.Replace("\n", "<br>"); MiscUtility.SetSelected(dropStatus.Items, info.Order_Status.ToString()); lblQuantity.Text = ConvertUtility.ToInt32(info.Order_Quantity).ToString(); lblPrice.Text = String.Format("{0:0,0}", info.Order_Price) + " VNÐ"; dtlProduct.DataSource = OrderDB.GetProductByOrderID(_orderid); dtlProduct.DataBind(); }
protected void dtlProduct_ItemCommand(object source, DataListCommandEventArgs e) { if (e.CommandName == "delete") { var contentid = ConvertUtility.ToInt32(e.CommandArgument); try { var orderProductInfo = OrderProductDB.GetInfo(_orderid, contentid); var deletePriceSum = orderProductInfo.PriceSum; OrderProductDB.Delete(_orderid, contentid); var orderInfo = OrderDB.GetInfo(_orderid); orderInfo.Order_Quantity = orderInfo.Order_Quantity - 1; orderInfo.Order_Price = orderInfo.Order_Price - deletePriceSum; OrderDB.Update(orderInfo); lblUpdateStatus.Text = MiscUtility.UPDATE_SUCCESS; } catch { lblUpdateStatus.Text = MiscUtility.UPDATE_ERROR; } } if (e.CommandName == "updaterow") { //try //{ var contentid = ConvertUtility.ToInt32(e.CommandArgument); var txtQuantity = (TextBox)e.Item.FindControl("txtQuantity"); var orderProductInfo = OrderProductDB.GetInfo(_orderid, contentid); var newQuantity = ConvertUtility.ToInt32(txtQuantity.Text); var newPriceSum = orderProductInfo.Price * newQuantity; var balancePrice = orderProductInfo.PriceSum - newPriceSum; orderProductInfo.Quantity = newQuantity; orderProductInfo.PriceSum = newPriceSum; OrderProductDB.Update(orderProductInfo); var orderInfo = OrderDB.GetInfo(_orderid); orderInfo.Order_Price = orderInfo.Order_Price - balancePrice; OrderDB.Update(orderInfo); lblUpdateStatus.Text = MiscUtility.UPDATE_SUCCESS; //} //catch //{ // lblUpdateStatus.Text = MiscUtility.UPDATE_ERROR; //ex.ToString(); //} } }
protected void butUpdate_Click(object sender, EventArgs e) { int orderid = ConvertUtility.ToInt32(Request.QueryString["orderid"]); OrderInfo info = OrderDB.GetInfo(orderid); info.Order_Status = ConvertUtility.ToInt32(dropStatus.SelectedValue); try { OrderDB.Update(info); lblUpdateStatus.Text = MiscUtility.UPDATE_SUCCESS; } catch { lblUpdateStatus.Text = MiscUtility.UPDATE_ERROR; } }
protected void butUpdateAll_Click(object sender, EventArgs e) { try { foreach (DataGridItem item in dtgOrder.Items) { int id = ConvertUtility.ToInt32(item.Cells[0].Text); OrderInfo info = OrderDB.GetInfo(id); var dropStatus = (DropDownList)item.FindControl("dropStatus"); info.Order_Status = ConvertUtility.ToInt32(dropStatus.SelectedValue); OrderDB.Update(info); } lblUpdateStatus.Text = MiscUtility.UPDATE_SUCCESS; } catch { lblUpdateStatus.Text = MiscUtility.UPDATE_ERROR; //ex.ToString(); } }
protected void dtgProduct_ItemCommand(object source, DataGridCommandEventArgs e) { if (e.CommandName == "delete") { int id = ConvertUtility.ToInt32(e.Item.Cells[0].Text); try { OrderDB.Delete(id); lblUpdateStatus.Text = MiscUtility.UPDATE_SUCCESS; } catch { lblUpdateStatus.Text = MiscUtility.UPDATE_ERROR; } } if (e.CommandName == "updaterow") { try { int id = ConvertUtility.ToInt32(e.Item.Cells[0].Text); OrderInfo info = OrderDB.GetInfo(id); var dropStatus = (DropDownList)e.Item.FindControl("dropStatus"); info.Order_Status = ConvertUtility.ToInt32(dropStatus.SelectedValue); OrderDB.Update(info); lblUpdateStatus.Text = MiscUtility.UPDATE_SUCCESS; } catch { lblUpdateStatus.Text = MiscUtility.UPDATE_ERROR; //ex.ToString(); } } }