コード例 #1
0
        protected void LinkButton1_Click(object sender, EventArgs e)
        {
            int        id  = Int32.Parse((sender as LinkButton).CommandArgument);
            Promotions lst = new PromotionAccess().Getpro(id);

            con = new SqlConnection(constr);
            SqlDataAdapter da = new SqlDataAdapter("select s.Basics,s.EmpID, s.HouseRent,s.Medical,s.Convences,s.Taxes,s.Gross_Salary from SalaryHistory s where EmpID=" + id + ";", con);
            DataTable      dt = new DataTable();

            da.Fill(dt);
            Label1.Text   = dt.Rows[0]["Basics"].ToString();
            Label2.Text   = dt.Rows[0]["HouseRent"].ToString();
            Label3.Text   = dt.Rows[0]["Medical"].ToString();
            Label4.Text   = dt.Rows[0]["Convences"].ToString();
            Label5.Text   = dt.Rows[0]["Taxes"].ToString();
            Label6.Text   = dt.Rows[0]["Gross_Salary"].ToString();
            TextBox1.Text = dt.Rows[0]["EmpID"].ToString();

            double previous = double.Parse(dt.Rows[0]["Gross_Salary"].ToString());

            HiddenField2.Value          = previous.ToString();
            TextBox1.Text               = lst.empid.ToString();
            TextBox2.Text               = lst.amount.ToString();
            TextBox3.Text               = lst.Basic.ToString();
            TextBox4.Text               = lst.HouseRent.ToString();
            TextBox5.Text               = lst.Medicalmoney.ToString();
            TextBox6.Text               = lst.Convences.ToString();
            TextBox7.Text               = lst.taxes.ToString();
            TextBox8.Text               = lst.Gross_Salary.ToString();
            TextBox9.Text               = lst.activedate.ToString();
            TextBox10.Text              = lst.pro_active.ToString();
            DropDownList1.SelectedValue = lst.pro_type.ToString();
            HiddenField1.Value          = id.ToString();
        }
コード例 #2
0
        protected void Button4_Click(object sender, EventArgs e)
        {
            int        id  = Convert.ToInt32(HiddenField1.Value);
            Promotions dpt = new Promotions();

            dpt.empid    = Int32.Parse(TextBox1.Text);
            dpt.pro_type = DropDownList1.SelectedValue;
            dpt.amount   = double.Parse(TextBox2.Text);

            dpt.activedate = DateTime.Parse(TextBox9.Text);
            dpt.pro_active = DateTime.Parse(TextBox10.Text);
            dpt.id         = id;

            dpt.Basic        = double.Parse(TextBox3.Text);
            dpt.HouseRent    = double.Parse(TextBox4.Text);
            dpt.Medicalmoney = double.Parse(TextBox5.Text);
            dpt.Convences    = double.Parse(TextBox6.Text);
            dpt.taxes        = double.Parse(TextBox7.Text);
            dpt.Gross_Salary = double.Parse(TextBox8.Text);
            PromotionAccess manager = new PromotionAccess();

            if (manager.Update(dpt) > 0)
            {
                ScriptManager.RegisterStartupScript(this, this.GetType(), "ClientScript", "alert('Successfully Updated')", true);
                GridView1.DataBind();
            }
            else
            {
                ScriptManager.RegisterStartupScript(this, this.GetType(), "ClientScript", "alert('Update Fail')", true);
            }
            //int id = Int32.Parse(TextBox1.Text.ToString());
            //Promotions lst = new PromotionAccess().Getpro(id);


            //TextBox2.Text=lst.amount.ToString();
            //TextBox3.Text=lst.Basic.ToString();
            //TextBox4.Text=lst.HouseRent.ToString();
            //TextBox5.Text=lst.Medicalmoney.ToString();
            //TextBox6.Text=lst.Convences.ToString();
            //TextBox7.Text=lst.taxes.ToString();
            //TextBox8.Text=lst.Gross_Salary.ToString();
            //TextBox9.Text=lst.activedate.ToString();
            //TextBox10.Text = lst.pro_active.ToString();
            //DropDownList1.SelectedValue = lst.pro_type.ToString();
        }