Beispiel #1
0
        private void btnSpecific_Click(object sender, EventArgs e)
        {
            Commons.SELECTED_PLAN = SELECTED_MODEL;

            Commons.USER_STD_1 = User_std1;
            Commons.USER_STD_2 = User_std2;
            Commons.USER_STD_3 = User_std3;

            try
            {
                using (SqlConnection conn = new SqlConnection(Commons.CONNSTRING))
                {
                    DataSet ds = new DataSet();
                    conn.Open();

                    // 2개의 파라미터 정의 (항상 @로 시작)
                    string sql = " SELECT  STD1,STD2,STD3 " +
                                 " FROM dbo.productTbl WHERE CallingPlan = @CallingPlan";
                    SqlCommand cmd = new SqlCommand(sql, conn);

                    // 각 파라미터 타입 및 값 입력
                    SqlParameter paramCity = new SqlParameter("@CallingPlan", SqlDbType.NVarChar, 50);
                    paramCity.Value = SELECTED_MODEL;
                    // SqlCommand 객체의 Parameters 속성에 추가
                    cmd.Parameters.Add(paramCity);



                    SqlDataAdapter adapter = new SqlDataAdapter(cmd);
                    adapter.Fill(ds, "User_Information");

                    conn.Close();
                    priceTbl.DataSource = ds; //그리드의 데이터 소스에다가 붓는다.
                    priceTbl.DataMember = "User_Information";
                }
                Commons.SELECTED_PLAN = SELECTED_MODEL;

                Product_std1 = int.Parse(priceTbl[0, 0].Value.ToString());
                Product_std2 = int.Parse(priceTbl[1, 0].Value.ToString());
                Product_std3 = int.Parse(priceTbl[2, 0].Value.ToString());



                Specific_Form form = new Specific_Form();
                InitChildForm(form, "");
                SELECTED_MODEL = "";

                Calculate_Favor_Specific();
            }
            catch (Exception)
            {
            }

            using (SqlConnection conn = new SqlConnection(Commons.CONNSTRING))
            {
                conn.Open();
                SqlCommand cmd = new SqlCommand();
                cmd.Connection = conn;


                cmd.CommandText = " UPDATE dbo.userTbl " +
                                  " SET STD1 = @STD1, STD2 = @STD2, STD3 = @STD3 " +
                                  " WHERE userID = @userID";

                SqlParameter parmSTD1 = new SqlParameter("@STD1", SqlDbType.Int);
                parmSTD1.Value = User_std1;
                cmd.Parameters.Add(parmSTD1);

                SqlParameter parSTD2 = new SqlParameter("@STD2", SqlDbType.Int);
                parSTD2.Value = User_std2;
                cmd.Parameters.Add(parSTD2);

                SqlParameter parmSTD3 = new SqlParameter("@STD3", SqlDbType.Int);
                parmSTD3.Value = User_std3;
                cmd.Parameters.Add(parmSTD3);

                SqlParameter parmuserID = new SqlParameter("@userID", SqlDbType.VarChar, 50);
                parmuserID.Value = Commons.LOGINUSERID;
                cmd.Parameters.Add(parmuserID);

                cmd.ExecuteNonQuery();    //excute는 넣을 때 쓰는건 NonQuery 그 외에건 가져올 때
            }
        }
Beispiel #2
0
 private void InitChildForm(Specific_Form form, string v)
 {
     form.Show();
     form.WindowState = FormWindowState.Normal;
 }