コード例 #1
0
    protected void btnAdd_Click(object sender, EventArgs e)
    {
        strtDsznfmjlb tmp = new strtDsznfmjlb();

            tmp.name = txtName.Text;
            tmp.sex = Convert.ToInt16(dplSex.SelectedIndex);
            tmp.birthday = Convert.ToDateTime(txtBirthday.Text);
            tmp.childbirthday = Convert.ToDateTime(txtChildBirthday.Text);
            tmp.childsex = Convert.ToInt16(dplChildSex.SelectedIndex);
            tmp.familycode = txtfamilyCode.Text;
            tmp.isoldinsure = Convert.ToInt16(chkIsOldInsure.Checked); //是否参加养老保险补贴(0 未 1  参加)
            tmp.locationcode = txtLocationCode.Text;
            tmp.lushi = Convert.ToInt16(chkLushi.Checked ? 1 : 0);
            tmp.lushidate = Convert.ToDateTime(txtLushiDate.Text);
            tmp.namelocation = txtLocation.Text;
            tmp.onechildcardcode = txtOneChildCardCode.Text;
            tmp.paydate = Convert.ToDateTime(txtPaydate.Text);
            tmp.paynum = Convert.ToDouble(txtPaynum.Text);
            tmp.poldcode = txtPoldcode.Text;
            tmp.poname = txtPoName.Text;
            tmp.shenghe = Convert.ToInt16(dplShenghe.SelectedIndex);
            tmp.shenghedate = Convert.ToDateTime(txtShenghedate.Text);
            tmp.shenghenoreason = txtShengheNoReason.Text;
            tmp.shengheren = txtShengheRen.Text;
            tmp.unitname = txtUnitName.Text;
            tmp.unitxingzhi = Convert.ToInt16(dplUnitXingzhi.SelectedIndex);
            tmp.username = Session["UserName"].ToString();
            tmp.inputdate = DateTime.Now;

            string strSQL = Table_Dsznfmjlb.GetSQL_Insert(tmp);

            rwDB db = new rwDB();
            db.ExcuteSQL(strSQL);
    }
コード例 #2
0
    protected void ImageButton1_Click1(object sender, ImageClickEventArgs e)
    {
        //string uname = Request["username"];
        //string upassword = Request["password"];

        //stockClass sc = new stockClass();

        //string sqlConStr = "Server=Localhost;Integrated Security=True;DataBase=lydxDB;";
        //SqlConnection sqlcon = new SqlConnection(sqlConStr);

        //try
        //{
        //    sqlcon.Open();
        //    //SqlDataAdapter oda = new SqlDataAdapter("select * from [User]", sqlcon);
        //    //DataSet ds = new DataSet();

        //    //oda.Fill(ds);
        //    //GridView1.DataSource = ds;
        //    //GridView1.DataBind();

        //    //Response.Write("<script language=javascript>alert('访问成功')</script>");

        //    string cmdText = "select * from [User] where Name='"
        //                      + username.Text.Trim() +"' and Password ='******'";
        //    SqlCommand cmd = new SqlCommand(cmdText, sqlcon);

        //    SqlDataReader dr = cmd.ExecuteReader();
        //    if(dr.Read())
        //    {
        //        //string value = dr["Name"].ToString();
        //        //Response.Write(value + "<br />");

        //        Session["UserName"] = username.Text;
        //        Session["LoginTime"] = DateTime.Now;
        //        Response.Redirect("default2.aspx");

        //    }
        //    else
        //    {
        //       Response.Write("<script>alert('用户名或密码错误!');history.back()</script>");
        //    }

        //    dr.Close();

        //}
        //catch (Exception error)
        //{
        //    Response.Write(error.ToString());
        //    Response.Write("<script>alert('访问失败')</script>");
        //}
        //finally
        //{
        //    sqlcon.Close();
        //}

        try
        {

        string uname = Request["username"];
        string upassword = Request["password"];
        rwDB db = new rwDB();
        string strSQL = "select password from users where user='******' and password='******'";
        DataTable dttTmp = db.GetDataTable(strSQL);
        if (dttTmp != null && dttTmp.Rows.Count > 0)
        {
            Session["UserName"] = username.Text;
            Session["LoginTime"] = DateTime.Now;
            Response.Redirect("default2.aspx");
        }
        else
        {
            Response.Write("<script>alert('用户名或密码错误!');history.back()</script>");
        }
        }
        catch (System.Exception )
        {

        }
    }