Exemplo n.º 1
0
 private void 值btn修改店家_Click(object sender, EventArgs e)
 {
     try
     {
         DialogResult R;
         R = MessageBox.Show("確定修改資料?", "請再次確認", MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
         if ((R == DialogResult.OK) && (值tb店名.Text.Length > 0))
         {
             Form便當菜 myform便當菜 = new Form便當菜();
             int     int序號     = 0;
             Int32.TryParse(值lbl序號號碼.Text, out int序號);
             if ((值tb店名.Text.Length > 0) && (值tb電話.Text.Length > 0))
             {
                 SqlConnection con = new SqlConnection(scsb.ToString());
                 con.Open();
                 string     strSQL = "update StoreInfo set  StoreName=@NewStoreName,Valuation=@NewValuation,StoreAddress=@NewStoreAddress,StorePhoneNum=@NewStorePhoneNum,StoreRemark=@NewStoreRemark,StorePicture=@NewStorePicture where StoreID=@SearchSotreID";
                 SqlCommand cmd    = new SqlCommand(strSQL, con);
                 cmd.Parameters.AddWithValue("@SearchSotreID", int序號);
                 cmd.Parameters.AddWithValue("@NewStoreName", 值tb店名.Text);
                 cmd.Parameters.AddWithValue("@NewValuation", 值tb評價.Text);
                 cmd.Parameters.AddWithValue("@NewStoreAddress", 值tb地址.Text);
                 cmd.Parameters.AddWithValue("@NewStorePhoneNum", 值tb電話.Text);
                 cmd.Parameters.AddWithValue("@NewStoreRemark", 值tb備註欄.Text);
                 cmd.Parameters.AddWithValue("@NewStorePicture", 值tb輸入圖片位址.Text);
                 cmd.ExecuteNonQuery();
                 con.Close();
                 myform便當菜.StoreName = 值tb店名.Text;
                 myform便當菜.Show();
             }
         }
         else
         {
             MessageBox.Show("沒有可以修改的店家");
         }
     }
     catch
     {
         MessageBox.Show("評價請輸入0.0~5.0");
     }
 }
Exemplo n.º 2
0
        private void 值btn儲存_Click(object sender, EventArgs e)
        {
            try
            {
                if ((值tb店名.Text.Length > 0) && (值tb電話.Text.Length > 0))
                {
                    DialogResult R;
                    R = MessageBox.Show("確定資料正確?", "請再次確認", MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
                    if (R == DialogResult.OK)
                    {
                        Form便當菜       myform便當菜 = new Form便當菜();
                        SqlConnection con       = new SqlConnection(scsb.ToString());
                        con.Open();
                        string     strSQL = "insert into [StoreInfo] values(@NewStoreName,@NewValuation,@NewStoreAddress,@NewStorePhoneNum,@NewStoreRemark,@NewStroePicture)";
                        SqlCommand cmd    = new SqlCommand(strSQL, con);
                        cmd.Parameters.AddWithValue("@NewStoreName", 值tb店名.Text);
                        cmd.Parameters.AddWithValue("@NewValuation", 值tb評價.Text);
                        cmd.Parameters.AddWithValue("@NewStoreAddress", 值tb地址.Text);
                        cmd.Parameters.AddWithValue("@NewStorePhoneNum", 值tb電話.Text);
                        cmd.Parameters.AddWithValue("@NewStoreRemark", 值tb備註欄.Text);
                        cmd.Parameters.AddWithValue("@NewStroePicture", 值tb輸入圖片位址.Text);
                        cmd.ExecuteNonQuery();

                        con.Close();
                        myform便當菜.StoreName = 值tb店名.Text;
                        myform便當菜.Show();
                        comboBox2.Items.Add(值tb店名.Text);
                    }
                }
                else
                {
                    MessageBox.Show("請輸入完整資料!!!");
                }
            }
            catch
            {
                MessageBox.Show("評價請輸入0.0~5.0");
            }
        }