protected void btnEdit_Click(object sender, EventArgs e)
        {
            WaterLevelDam             WaterLevelDam             = new WaterLevelDam();
            WaterLevelDamTableAdapter WaterLevelDamTableAdapter = new WaterLevelDamTableAdapter();
            WaterLevelDam             originalWaterLevelDam     = WaterLevelDamTableAdapter.GetWaterLevelByID(Convert.ToInt32(Request["WaterLevelDamID"]));


            if (IsValidData())
            {
                WaterLevelDam.ID          = originalWaterLevelDam.ID;
                WaterLevelDam.DamID       = Convert.ToInt32(ddlDamName.SelectedValue);
                WaterLevelDam.DamName     = ddlDamName.SelectedItem.ToString();
                WaterLevelDam.LevelFeet   = txtWaterLevelFeet.Text.Trim();
                WaterLevelDam.Remark      = txtRemark.Text.Trim();
                WaterLevelDam.CreatedDate = Convert.ToDateTime(txtDate.Text);
                WaterLevelDam.CreatedTime = txtTime.Text;

                WaterLevelDam.Status = "ACTIVE";

                if (WaterLevelDamTableAdapter.Update(WaterLevelDam) > 0)
                {
                    ltlMessage.Text = "<div class=\"alert alert-success alert-dismissible\"><button type = \"button\" class=\"close\" data-dismiss=\"alert\" aria-hidden=\"true\">&times;</button> <h4><i class=\"icon fa fa-check\"></i> Alert!</h4> Sucessfully Updated <b>" + txtWaterLevelFeet.Text.Trim() + "</b>.</div>";
                    Response.Redirect("~/WaterLevelsDam/waterlevellistdam.aspx");
                }
            }
        }
Ejemplo n.º 2
0
        protected void btnYes_Click(object sender, EventArgs e)
        {
            WaterLevelDamTableAdapter WaterLevelDamTableAdapter = new WaterLevelDamTableAdapter();
            WaterLevelDam             originalWaterLevelDam     = WaterLevelDamTableAdapter.GetWaterLevelByID(Convert.ToInt32(Request["WaterLevelDamID"]));

            WaterLevelDam WaterLevelDam = new WaterLevelDam();

            WaterLevelDam.ID          = originalWaterLevelDam.ID;
            WaterLevelDam.DamID       = originalWaterLevelDam.DamID;
            WaterLevelDam.DamName     = originalWaterLevelDam.DamName;
            WaterLevelDam.LevelFeet   = originalWaterLevelDam.LevelFeet;
            WaterLevelDam.Remark      = originalWaterLevelDam.Remark;
            WaterLevelDam.CreatedDate = originalWaterLevelDam.CreatedDate;
            WaterLevelDam.CreatedTime = originalWaterLevelDam.CreatedTime;
            WaterLevelDam.Status      = "INACTIVE";
            if (WaterLevelDamTableAdapter.Update(WaterLevelDam) > 0)
            {
                ltlMessage.Text = "<div class=\"alert alert-success alert-dismissible\"><button type = \"button\" class=\"close\" data-dismiss=\"alert\" aria-hidden=\"true\">&times;</button> <h4><i class=\"icon fa fa-check\"></i> Alert!</h4> Sucessfully Deleted <b>" + originalWaterLevelDam.DamName + "</b>.</div>";
                Response.Redirect("~/WaterLevelsDam/waterlevellistdam.aspx");
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            ltlMessage.Text = null;
            if (!IsPostBack)
            {
                DamTableAdapter damTableAdapter = new DamTableAdapter();
                DataTable       dtDam           = damTableAdapter.GetDataByStatus("ACTIVE");
                ddlDamName.DataValueField = "ID";
                ddlDamName.DataTextField  = "DamName";
                ddlDamName.DataSource     = dtDam;
                ddlDamName.DataBind();

                ddlDamName.Items.Insert(0, new ListItem("Select Dam Name"));

                WaterLevelDamTableAdapter WaterLevelDamTableAdapter = new WaterLevelDamTableAdapter();
                WaterLevelDam             originalWaterLevelDam     = WaterLevelDamTableAdapter.GetWaterLevelByID(Convert.ToInt32(Request["WaterLevelDamID"]));

                ddlDamName.SelectedValue = originalWaterLevelDam.DamID.ToString();
                txtWaterLevelFeet.Text   = originalWaterLevelDam.LevelFeet;
                txtRemark.Text           = originalWaterLevelDam.Remark;
                txtDate.Text             = originalWaterLevelDam.CreatedDate.ToString("dd/MMM/yyyy");
                txtTime.Text             = originalWaterLevelDam.CreatedTime;
            }
        }