protected void grdtbCUSTOMERS_ItemCommand(object source, DataGridCommandEventArgs e) { string strCA = e.CommandArgument.ToString(); this.txtIdbill.Text = e.CommandArgument.ToString(); switch (e.CommandName) { case "Edit": { List<Data.tbBill_customers> listbillcus = Business.tbBill_customersService.tbBill_customers_GetById(strCA); if (listbillcus.Count > 0) { List<Data.tbCUSTOMERS> listcus = Business.tbCUSTOMERSService.tbCUSTOMERS_GetById(listbillcus[0].userid); this.grdtbCUSTOMERSinfo.DataSource = listcus; this.grdtbCUSTOMERSinfo.DataBind(); listcus.Clear(); listcus = null; //List<Data.tbRecipient> listReci = Business.tbRecipientService.tbRecipient_GetByTop("", "iusid=" + listbillcus[0].userid, ""); //this.grdRecipient.DataSource = listReci; //this.grdRecipient.DataBind(); //listReci.Clear(); //listReci = null; // Update trang thai Data.tbBill_customers obj = new tbBill_customers(); obj.billid = listbillcus[0].billid; obj.userid = listbillcus[0].userid; obj.totalmoney = listbillcus[0].totalmoney; obj.xdate = Common.DateTimeClass.ConvertDateTime(listbillcus[0].xdate.ToString(), "MM/dd/yyyy HH:mm:ss"); obj.idate = Common.DateTimeClass.ConvertDateTime(listbillcus[0].idate.ToString(), "MM/dd/yyyy HH:mm:ss"); obj.request = listbillcus[0].request; obj.typepay = listbillcus[0].typepay; obj.state = listbillcus[0].state; obj.lang = Lang; obj.show = "1"; tbBill_customersService.tbBill_customers_Update(obj); } List<Data.tbBilldetail> listBill = Business.tbBilldetailService.tbBilldetail_GetByTop("1000000000", "bilid=" + strCA, ""); this.grdshopcard.DataSource = listBill; this.grdshopcard.DataBind(); Double SumMoney = 0; for (int i = 0; i < listBill.Count; i++) { SumMoney += double.Parse(listBill[i].bilmoney.ToString()); } //this.lblsummoney.Text = Format_Price(SumMoney.ToString()); //SumMoney = SumMoney + double.Parse(Common.GlobalClass.FreeShipping); //lblmoneyphi.Text = Format_Price(Common.GlobalClass.FreeShipping); this.lblsumpay.Text = Format_Price(SumMoney.ToString()); listBill.Clear(); listBill = null; listbillcus.Clear(); listbillcus = null; pnView.Visible = false; pnUpdate.Visible = true; } break; case "Delete": try { tbBill_customersService.tbBill_customers_Delete(strCA); BindGrid(); } catch { Common.WebMsgBox.Show("Đơn hàng đã có dữ liệu đặt hàng không thể xóa"); return; } break; } }
protected void Update_Click(object sender, EventArgs e) { if (Page.IsValid) { List<Data.tbBill_customers> listbillcus = Business.tbBill_customersService.tbBill_customers_GetById(txtIdbill.Text.Trim()); if (listbillcus.Count > 0) { Data.tbBill_customers obj = new tbBill_customers(); obj.billid = listbillcus[0].billid; obj.userid = listbillcus[0].userid; obj.totalmoney = listbillcus[0].totalmoney; obj.xdate = Common.DateTimeClass.ConvertDateTime(DateTime.Now, "MM/dd/yyyy HH:mm:ss"); obj.idate = Common.DateTimeClass.ConvertDateTime(listbillcus[0].idate, "MM/dd/yyyy HH:mm:ss"); obj.request = listbillcus[0].request; obj.typepay = listbillcus[0].typepay; obj.state = "1"; obj.lang = Lang; obj.show = "1"; tbBill_customersService.tbBill_customers_Update(obj); } BindGrid(); pnView.Visible = true; pnUpdate.Visible = false; Insert = false; this.txtIdbill.Text = ""; } }