Beispiel #1
0
        protected void gvTransactionDetails_RowUpdating(object sender, GridViewUpdateEventArgs e)
        {
            Label        lblTransactionId   = (Label)gvTransactionDetails.Rows[e.RowIndex].FindControl("lblTransactionId");
            DropDownList ddlEditProduct     = (DropDownList)gvTransactionDetails.Rows[e.RowIndex].FindControl("ddlEditProduct");
            TextBox      txtEditComments    = (TextBox)gvTransactionDetails.Rows[e.RowIndex].FindControl("txtEditComments");
            TextBox      txtEditCount       = (TextBox)gvTransactionDetails.Rows[e.RowIndex].FindControl("txtEditCount");
            TextBox      txtEditTotalAmount = (TextBox)gvTransactionDetails.Rows[e.RowIndex].FindControl("txtEditTotalAmount");

            Domain.Transaction existing = transactionRepo.GetById(Convert.ToInt32(lblTransactionId.Text));
            if (existing != null)
            {
                existing.ProductId        = Convert.ToInt32(ddlEditProduct.SelectedValue);
                existing.Comments         = txtEditComments.Text;
                existing.Count            = Convert.ToInt32(txtEditCount.Text);
                existing.TotalAmount      = Convert.ToDecimal(txtEditTotalAmount.Text);
                existing.LastUpdatedBy    = "admin";
                existing.LastUpdationTime = DateTime.Now;
                existing.TenantId         = tenantId;
            }


            transactionRepo.Edit(existing);
            transactionRepo.Save();
            gvTransactionDetails.EditIndex = -1;
            BindData();
        }
Beispiel #2
0
        protected void gvTransactionDetails_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            try
            {
                if (e.CommandName.Equals("ADD"))
                {
                    DropDownList ddlAddProduct     = (DropDownList)gvTransactionDetails.FooterRow.FindControl("ddlAddProduct");
                    TextBox      txtAddComments    = (TextBox)gvTransactionDetails.FooterRow.FindControl("txtAddComments");
                    TextBox      txtAddCount       = (TextBox)gvTransactionDetails.FooterRow.FindControl("txtAddCount");
                    TextBox      txtAddTotalAmount = (TextBox)gvTransactionDetails.FooterRow.FindControl("txtAddTotalAmount");



                    Domain.Transaction transaction = new Domain.Transaction()
                    {
                        Comments         = txtAddComments.Text,
                        Count            = Convert.ToInt32(txtAddCount.Text),
                        ProductId        = Convert.ToInt32(ddlAddProduct.SelectedValue),
                        TotalAmount      = Convert.ToDecimal(txtAddTotalAmount.Text),
                        CreationTime     = DateTime.Now,
                        LastUpdationTime = DateTime.Now,
                        CreatedBy        = "admin",
                        LastUpdatedBy    = "admin",
                        TenantId         = tenantId,
                    };

                    transactionRepo.Add(transaction);
                    transactionRepo.Save();
                    BindData();
                }
            }

            catch (Exception ex)
            {
                Response.Write(ex.Message);
            }
        }