protected void GridViewPaidBills_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName == "Select_Bill") { long Bill_ID = Convert.ToInt64(((LinkButton)e.CommandSource).Text); // select bill info Bill bill = new Bill(); bill.Bill_ID = Bill_ID; double Cost, Paid_amount; bill = bill.Get_Bill_Info(out Cost, out Paid_amount); lblBill_ID.Text = Bill_ID.ToString(); lblBillDate.Text = bill.Bill_Date.ToShortDateString(); lblClientName.Text = bill.Client_Name; lblBillCost.Text = Cost.ToString(); if (bill.Discount == 0) { lblDiscountValue.Visible = false; lblDiscount.Visible = false; } else { lblDiscountValue.Text = bill.Discount.ToString(); } lblPaid_Value.Text = Paid_amount.ToString(); lblAdditionalCostValue.Text = bill.AdditionalCost.ToString(); lblAdditionalcostNotes.Text = bill.AdditionalCostNotes; lblRest.Text = (Cost + bill.AdditionalCost - Paid_amount - bill.Discount) >= 0 ? (Cost + bill.AdditionalCost - Paid_amount - bill.Discount).ToString() : (-(Cost + bill.AdditionalCost - Paid_amount - bill.Discount)).ToString() + " " + "فرق تكلفه للعميل"; // select bill items ViewState["Bill_ID"] = Bill_ID; BindBill(Bill_ID); GridViewPayments.DataSource = Bill_Payments.Get_Bill_Payments(Bill_ID); GridViewPayments.DataBind(); PanelBill.Visible = true; PanelBills.Visible = false; } }
protected void ImageButtonSearch_Click(object sender, ImageClickEventArgs e) { PanelBill.Visible = false; if (TextBoxSearch.Visible) { Bill bill = new Bill(); bill.Client_Name = TextBoxSearch.Text; if (string.IsNullOrEmpty(TextBoxSearch.Text) || !bill.IsExistsBill()) { PanelBills.Visible = false; PanelErrorMessage.Visible = true; } else { PanelBills.Visible = true; PanelErrorMessage.Visible = false; PanelPaidBills.Visible = true; PanelUnPaidBills.Visible = false; lnkBtnPaidBills.ForeColor = System.Drawing.Color.White; lnkBtnUnpaidBills.ForeColor = System.Drawing.Color.Black; GridViewPaidBills.PageIndex = 0; } } else // search by Bill_ID { Bill bill = new Bill(); bill.Bill_ID = txtBill_ID.Text != "" ? Convert.ToInt64(txtBill_ID.Text) : 0; if (string.IsNullOrEmpty(txtBill_ID.Text) || !bill.IsExistsBillWithID()) { PanelBills.Visible = false; PanelErrorMessage.Visible = true; } else { PanelErrorMessage.Visible = false; PanelBill.Visible = true; double Cost, Paid_amount; bill = bill.Get_Bill_Info(out Cost, out Paid_amount); lblBill_ID.Text = txtBill_ID.Text; lblBillDate.Text = bill.Bill_Date.ToShortDateString(); lblClientName.Text = bill.Client_Name; lblBillCost.Text = Cost.ToString(); if (bill.Discount == 0) { lblDiscountValue.Visible = false; lblDiscount.Visible = false; } else { lblDiscountValue.Text = bill.Discount.ToString(); } lblPaid_Value.Text = Paid_amount.ToString(); lblAdditionalCostValue.Text = bill.AdditionalCost.ToString(); lblAdditionalcostNotes.Text = bill.AdditionalCostNotes; lblRest.Text = (Cost + bill.AdditionalCost - Paid_amount - bill.Discount) >= 0 ? (Cost + bill.AdditionalCost - Paid_amount - bill.Discount).ToString() : (-(Cost + bill.AdditionalCost - Paid_amount - bill.Discount)).ToString() + " " + "فرق تكلفه للعميل"; // select bill items ViewState["Bill_ID"] = txtBill_ID.Text; BindBill(Convert.ToInt64(txtBill_ID.Text)); GridViewPayments.DataSource = Bill_Payments.Get_Bill_Payments(Convert.ToInt64(txtBill_ID.Text)); GridViewPayments.DataBind(); } } }