示例#1
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (Request.Cookies["user"] == null)
     {
         Response.Redirect("~/Default.aspx");
     }
     else
     {
         if (!new UserSecurity().CheckFormPermission((int)Global.formSecurity.ViewSupplierInvoice, Request.Cookies["user"]["Permission"].ToString()))
         {
             Response.Redirect("~/Finance_Module/UnAuthorized.aspx");
         }
     }
     if (Convert.ToInt32(Request.QueryString["id"].ToString()) > 0)
     {
         SupplierInvoice s = new SupplierInvoice();
         s.get(Convert.ToInt32(Request.QueryString["id"].ToString()));
         txtDescription.Text                 = s.Description;
         txtInvoiceNumber.Text               = s.InvoiceNumber.ToString();
         txtPaidAmount.Text                  = s.PaidAmount.ToString();
         txtRemaining.Text                   = s.RemainingAmount.ToString();
         txtTotalAmount.Text                 = s.TotalAmount.ToString();
         ddlCashGlAccount.SelectedValue      = s.InvoiceGLAcct.ToString();
         ddlliabilityGlAccount.SelectedValue = s.InvoiceLiabGLAcct.ToString();
         ddlSupplier.SelectedValue           = s.SupplierID.ToString();
         DataTable dt = s.getInvItems(Convert.ToInt32(Request.QueryString["id"].ToString()));
         grid.DataSource  = dt;
         Session["Table"] = dt;
         grid.DataBind();
     }
 }
        protected void Page_Init(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                if (Request.QueryString["alert"] == "noProducts")
                {
                    Response.Write("<script>alert('من فضلك ادخل منتج واحد على الاقل');</script>");
                }
                if (Request.QueryString["alert"] == "notpass")
                {
                    Response.Write("<script>alert('لم يتم الحفظ');</script>");
                }
                Session["Table"] = null;
                if (Convert.ToInt32(Request.QueryString["id"].ToString()) > 0)
                {
                    SupplierInvoice PPI = new SupplierInvoice();
                    DataTable       dt  = PPI.getInvItems(Convert.ToInt32(Request.QueryString["id"].ToString()));
                    grid.DataSource   = dt;
                    grid.KeyFieldName = "ID";
                    grid.DataBind();
                    btnEdit.Visible = true;
                    btnSave.Visible = false;
                    DataColumn colid = dt.Columns["ID"];
                    dt.PrimaryKey  = new DataColumn[] { colid };
                    colid.ReadOnly = true;


                    Session["Table"] = dt;
                }
                else
                {
                    grid.DataSource   = GetTable();
                    grid.KeyFieldName = "ID";
                    grid.DataBind();
                }
            }
        }