コード例 #1
0
        private void btn_register_stock_Click(object sender, EventArgs e)
        {
            frm_Register register = new frm_Register();

            register.Show();
            register.frm_Stock = this;
        }
コード例 #2
0
        private void btn_save_register_Click(object sender, EventArgs e)
        {
            frm_Register frm = new frm_Register();

            frm.Show();
            try
            {
                if (string.IsNullOrEmpty((txt_importprice_register.Text)) || string.IsNullOrEmpty(txt_name_register.Text) || string.IsNullOrEmpty(txt_sellprice_register.Text) ||
                    string.IsNullOrEmpty(lst_category_register.Text))
                {
                    MessageBox.Show("Please enter all field!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else
                {
                    str = "Data Source=.;Initial Catalog=skin_cilinic;Integrated Security=True";
                    con = new SqlConnection(str);
                    con.Open();
                    if (lst_category_register.SelectedIndex != (lst_category_register.Items.Count - 1))
                    {
                        spl = lst_category_register.Text.Split('.');
                        SqlCommand cmd = new SqlCommand("dbo.sp_insert_product", con);
                        cmd.CommandType = CommandType.StoredProcedure;
                        cmd.Parameters.AddWithValue("@pn", txt_name_register.Text);
                        cmd.Parameters.AddWithValue("@ci", (int)dic_category[lst_category_register.SelectedItem]);
                        cmd.Parameters.AddWithValue("@ps", txt_sellprice_register.Text);
                        cmd.Parameters.AddWithValue("@pu", txt_importprice_register.Text);
                        cmd.Parameters.AddWithValue("@q", 0);
                        cmd.ExecuteNonQuery();
                        txt_importprice_register.Clear();
                        txt_name_register.Clear();
                        txt_sellprice_register.Clear();
                        lst_category_register.Text = "";
                        MessageBox.Show("Your data have been saved!", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        con.Close();
                    }
                    else
                    {
                        SqlCommand cmd = new SqlCommand("dbo.sp_insert_product", con);
                        cmd.CommandType = CommandType.StoredProcedure;


                        cmd.Parameters.AddWithValue("@pn", txt_name_register.Text);
                        cmd.Parameters.AddWithValue("@cn", lst_category_register.Text);
                        cmd.Parameters.AddWithValue("@ps", txt_sellprice_register.Text);
                        cmd.Parameters.AddWithValue("@pu", txt_importprice_register.Text);
                        cmd.Parameters.AddWithValue("@q", 0);
                        cmd.ExecuteNonQuery();
                        txt_importprice_register.Clear();
                        txt_name_register.Clear();
                        txt_sellprice_register.Clear();
                        lst_category_register.Text = "";
                        con.Close();
                        MessageBox.Show("Your data have been saved!", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                }
                this.frm_Stock.refresh_frmstock();
            }
            catch (SqlException x)
            {
                MessageBox.Show(x.Message);
            }
            this.Close();
        }
コード例 #3
0
        private void btn_Register_Click(object sender, EventArgs e)
        {
            frm_Register register = new frm_Register();

            register.Show();
        }