Esempio n. 1
0
        protected void gvFeatureDetails_RowUpdating(object sender, GridViewUpdateEventArgs e)
        {
            Label   lblFeatureId       = (Label)gvFeatureDetails.Rows[e.RowIndex].FindControl("lblFeatureId");
            TextBox txtEditFeatureName = (TextBox)gvFeatureDetails.Rows[e.RowIndex].FindControl("txtEditFeatureName");
            TextBox txtEditDescription = (TextBox)gvFeatureDetails.Rows[e.RowIndex].FindControl("txtEditDescription");

            Domain.Feature existing = featureRepo.GetById(Convert.ToInt32(lblFeatureId.Text));
            if (existing != null)
            {
                existing.FeatureName        = txtEditFeatureName.Text;
                existing.FeatureDescription = txtEditDescription.Text;
                existing.LastUpdatedBy      = "admin";
                existing.LastUpdationTime   = DateTime.Now;
            }


            featureRepo.Edit(existing);
            featureRepo.Save();
            gvFeatureDetails.EditIndex = -1;
            BindData();

            //conn.Open();
            //string cmdstr = "update EmployeeDetails set name=@name,designation=@designation,city=@city,country=@country where empid=@empid";
            //SqlCommand cmd = new SqlCommand(cmdstr, conn);
            //cmd.Parameters.AddWithValue("@empid", lblEditEmpID.Text);
            //cmd.Parameters.AddWithValue("@name", txtEditName.Text);
            //cmd.Parameters.AddWithValue("@designation", txtEditDesignation.Text);
            //cmd.Parameters.AddWithValue("@city", txtEditCity.Text);
            //cmd.Parameters.AddWithValue("@country", txtEditCountry.Text);
            //cmd.ExecuteNonQuery();
            //conn.Close();
            //gvFeatureDetails.EditIndex = -1;
            //BindData();
        }
Esempio n. 2
0
        protected void gvFeatureDetails_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            try
            {
                if (e.CommandName.Equals("ADD"))
                {
                    TextBox txtAddFeatureName = (TextBox)gvFeatureDetails.FooterRow.FindControl("txtAddFeatureName");
                    TextBox txtAddDescription = (TextBox)gvFeatureDetails.FooterRow.FindControl("txtAddDescription");


                    Domain.Feature feature = new Domain.Feature()
                    {
                        FeatureDescription = txtAddDescription.Text,
                        FeatureName        = txtAddFeatureName.Text,
                        CreationTime       = DateTime.Now,
                        LastUpdationTime   = DateTime.Now,
                        CreatedBy          = "admin",
                        LastUpdatedBy      = "admin",
                    };

                    featureRepo.Add(feature);
                    featureRepo.Save();
                    BindData();
                }
            }

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