private void 值輸btn登入值日生系統_Click(object sender, EventArgs e) { if ((tb值日生姓名.Text.Length > 0) && (tb值日生班級.Text.Length > 0) && (tb值日生電話.Text.Length > 0)) { SqlConnection con = new SqlConnection(scsb.ToString()); con.Open(); string strSQL = "Insert Into 值日生Info(@new值日生班級,@new值日生姓名,@new值日生電話)"; SqlCommand cmd = new SqlCommand(strSQL, con); cmd.Parameters.AddWithValue("@New值日生班級", tb值日生班級.Text); cmd.Parameters.AddWithValue("@New值日生姓名", tb值日生姓名.Text); cmd.Parameters.AddWithValue("@New值日生電話", tb值日生電話.Text); Form值日生端 myform值日生端 = new Form值日生端(); Form學生端 myform學生端 = new Form學生端(); Form值日生輸入 myform值日生輸入資料 = new Form值日生輸入(); Form櫃台端 myform櫃台端 = new Form櫃台端(tb值日生姓名.Text); myform值日生端.Show(); //myform值日生端.ShowDialog(); myform值日生輸入資料.ShowInTaskbar = false; myform學生端.Show(); //myform學生端.ControlBox = false; //myform學生端.WindowState = FormWindowState.Minimized; myform學生端.Dispose(); con.Close(); } else { MessageBox.Show("請輸入完整資料"); } }
private void F1btn櫃台_Click(object sender, EventArgs e) { //if (myform櫃台端.Visible == false) //{ // myform櫃台端.Visible = true; //} //myform櫃台端.WindowState = FormWindowState.Normal; try { Form櫃台端 myform櫃台端 = new Form櫃台端(); //scsb = new SqlConnectionStringBuilder(); //scsb.DataSource = @"."; //scsb.InitialCatalog = "MidReport"; //scsb.IntegratedSecurity = true; SqlConnection con = new SqlConnection(scsb.ToString()); con.Open(); string strSQLTotal = "select StoreFood, SUM(Price) AS TotalPrice,SUM(Amount) AS TotalAmount From FormStudentChoice Group By StoreFood"; SqlCommand cmd1 = new SqlCommand(strSQLTotal, con); string StrTTTTT = ""; string strStoreFoodMsg = ""; string strtotalMsg = ""; int strtotalMsgS = 0; string strtotalMsg1 = ""; int strtotalMsg1S = 0; SqlDataReader reader = cmd1.ExecuteReader(); while (reader.Read() == true) { strStoreFoodMsg = string.Format("{0}", reader["StoreFood"]); strtotalMsg = string.Format("{0}", reader["TotalPrice"]); strtotalMsg1 = string.Format("{0}", reader["TotalAmount"]); StrTTTTT = strStoreFoodMsg + " " + "總價:" + strtotalMsg + " " + "總數:" + strtotalMsg1; myform櫃台端.list.Add(StrTTTTT); //櫃lbox.Items.Add(StrTTTTT);/****************************************/ myform櫃台端.strtotalMsgS += Convert.ToInt32(strtotalMsg); myform櫃台端.strtotalMsg1S += Convert.ToInt32(strtotalMsg1); } reader.Close(); string strMsg = " select top 1 * From DutyInfoS order by DutyID desc"; SqlCommand cmd = new SqlCommand(strMsg, con); SqlDataReader reader1 = cmd.ExecuteReader(); reader1.Read(); string strDutyClass = ""; string strDutyName = ""; //string strDutyPhoneNum = ""; myform櫃台端.strDutyClass = string.Format("{0}", reader1["DutyClass"]); myform櫃台端.strDutyName = string.Format("{0}", reader1["DutyName"]); //strDutyPhoneNum = string.Format("{0}", reader1["DutyPhoneNum"]); //櫃lbl班級輸出.Text = strDutyClass;/*******************************************/ //櫃lbl值日生輸出.Text = strDutyName;/*******************************************/ //櫃lbl便當總數輸出.Text = strtotalMsg1S.ToString();/*********************************/ //櫃lbl總價輸出.Text = strtotalMsgS.ToString();/***********************************/ reader1.Close(); string strMsg2 = " select top 1 * From StoreInfoS order by StoreID desc"; SqlCommand cmd2 = new SqlCommand(strMsg2, con); SqlDataReader reader2 = cmd2.ExecuteReader(); string strStoreName = ""; string strStorePhoneNum = ""; //string strDutyPhoneNum = ""; reader2.Read(); myform櫃台端.strStoreName = string.Format("{0}", reader2["StoreName"]); myform櫃台端.strStorePhoneNum = string.Format("{0}", reader2["StorePhoneNum"]); //櫃lbl店名輸出.Text = strStoreName;/**************************************/ //櫃lbl電話輸出.Text = strStorePhoneNum;/*************************************/ con.Close(); myform櫃台端.Show(); } catch { MessageBox.Show("尚未完成訂單"); } }