Пример #1
0
        protected void grid_RowUpdating(object sender, DevExpress.Web.Data.ASPxDataUpdatingEventArgs e)
        {
            ASPxGridView grid = sender as ASPxGridView;

            DataTable table = new DataTable();

            if (Convert.ToInt32(Request.QueryString["id"].ToString()) > 0)
            {
                ProductPriceItems PPI = new ProductPriceItems();
                table = PPI.getByProductID(Convert.ToInt32(Request.QueryString["id"].ToString()));
                DataColumn colid = table.Columns[0];
                table.PrimaryKey = new DataColumn[] { colid };
            }
            else
            {
                table = GetTable();
            }
            DataRow found = table.Rows.Find(e.Keys[0]);

            found["ProductID"]   = e.NewValues["ProductID"];
            found["itemprice"]   = e.NewValues["itemprice"];
            found["ProductID"]   = e.NewValues["ProductID"];
            found["Quantity"]    = e.NewValues["Quantity"];
            found["GLAccountID"] = e.NewValues["GLAccountID"];

            Session["Table"] = table;
            grid.DataSource  = table;
            grid.DataBind();
            e.Cancel = true;
            grid.CancelEdit();
        }
Пример #2
0
        protected void Page_Init(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                if (Request.QueryString["alert"] == "notpass")
                {
                    Response.Write("<script>alert('لم يتم الحفظ');</script>");
                }
                Session["Table"] = null;
                if (Convert.ToInt32(Request.QueryString["id"].ToString()) > 0)
                {
                    ProductPriceItems PPI = new ProductPriceItems();
                    DataTable         dt  = PPI.getByProductID(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();
                }
            }
        }
Пример #3
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.ViewProduct, Request.Cookies["user"]["Permission"].ToString()))
                {
                    Response.Redirect("~/Finance_Module/UnAuthorized.aspx");
                }
            }
            if (Convert.ToInt32(Request.QueryString["ID"].ToString()) > 0)
            {
                Product product = new Product();
                product.get(Convert.ToInt32(Request.QueryString["ID"].ToString()));
                lblProductID.Text        = product.ID.ToString();
                lblProductName.Text      = product.Name.ToString();
                lblCreationDate.Text     = product.CreationDate.ToShortDateString();
                lblLastModifiedDate.Text = product.LastModifiedDate.ToShortDateString();
                lblType.Text             = product.TypeID.ToString();
                lblCost.Text             = product.Cost.ToString();
                lblPrice.Text            = product.Price.ToString();
                ProductPriceItems PPI = new ProductPriceItems();
                ASPxGridView2.DataSource = PPI.getByProductID(Convert.ToInt32(Request.QueryString["ID"].ToString()));
                ASPxGridView2.DataBind();

                DataTable dt = product.getProductCustomers(Convert.ToInt32(Request.QueryString["ID"].ToString()));
                ASPxGridView1.DataSource = dt;
                ASPxGridView1.DataBind();
            }
        }
Пример #4
0
        protected void grid_RowUpdating(object sender, DevExpress.Web.Data.ASPxDataUpdatingEventArgs e)
        {
            ASPxGridView grid = sender as ASPxGridView;

            DataTable table = new DataTable();

            if (Convert.ToInt32(Request.QueryString["id"].ToString()) > 0)
            {
                ProductPriceItems PPI = new ProductPriceItems();
                table = PPI.getByProductID(Convert.ToInt32(Request.QueryString["id"].ToString()));
                DataColumn colid = table.Columns[0];
                table.PrimaryKey = new DataColumn[] { colid };
            }
            else
            {
                table = GetTable();
            }
            ///Check the account balance
            GLAccount acc = new GLAccount();

            acc.get(int.Parse(e.NewValues["GLAccountID"].ToString()));
            if (acc.AcctType == 1 || acc.AcctType == 5)//depit acount (asset and expenses)
            {
                if (e.NewValues["Credit"] != null && e.NewValues["Credit"].ToString() != "")
                {
                    if (acc.Balance < decimal.Parse(e.NewValues["Credit"].ToString()))
                    {
                        throw new Exception("Account Balance(" + acc.Balance.ToString() + ") not enough");
                    }
                }
            }
            else
            {
                if (e.NewValues["Depit"] != null && e.NewValues["Depit"].ToString() != "")
                {
                    if (acc.Balance < decimal.Parse(e.NewValues["Depit"].ToString()))
                    {
                        throw new Exception("Account Balance(" + acc.Balance.ToString() + ") not enough");
                    }
                }
            }
            /////////////////////////////
            DataRow found = table.Rows.Find(e.Keys[0]);

            found["GLAccountID"] = e.NewValues["GLAccountID"];
            found["Depit"]       = e.NewValues["Depit"];
            found["Credit"]      = e.NewValues["Credit"];
            found["Memo"]        = e.NewValues["Memo"];
            found["acctType"]    = int.Parse(e.NewValues["GLAccountID"].ToString()) < 0 ? 1 : 0;
            Session["Table"]     = table;
            grid.DataSource      = table;
            grid.DataBind();
            e.Cancel = true;
            grid.CancelEdit();
        }
Пример #5
0
        protected void grid_RowDeleting(object sender, DevExpress.Web.Data.ASPxDataDeletingEventArgs e)
        {
            ASPxGridView grid  = sender as ASPxGridView;
            DataTable    table = new DataTable();

            if (Convert.ToInt32(Request.QueryString["id"].ToString()) > 0)
            {
                ProductPriceItems PPI = new ProductPriceItems();
                table = PPI.getByProductID(Convert.ToInt32(Request.QueryString["id"].ToString()));
                if (table.Rows.Count > 0)
                {
                    if (Session["Table"] == null)
                    {
                        DataColumn colid = table.Columns[0];
                        table.PrimaryKey = new DataColumn[] { colid };
                    }
                    else
                    {
                        table = GetTable();
                    }
                }
                else
                {
                    table = GetTable();
                }
            }
            else
            {
                table = GetTable();
            }

            DataRow found = table.Rows.Find(e.Keys[0]);

            table.Rows.Remove(found);

            Session["Table"] = table;
            grid.DataSource  = table;
            grid.DataBind();
            e.Cancel = true;
        }