/*--- 視窗拖移功能 ---*/ private void formBar_MouseDown(object sender, MouseEventArgs e) { FormFunction.FormMobileFunction(this.Handle); //重新取得主視窗位置 mainFormLocation = this.Location; }
/// <summary> /// Klasskonstruktor. Skapar formulär i enlighet med vald funktion /// </summary> /// <param name="product">Vilken produkt som ska visas i formuläret</param> /// <param name="formFunction">Vilken funktion formuläret ska anta.</param> /// <param name="maxQty">Maxantal av en produkt</param> public ProductForm(Product product, FormFunction formFunction, uint maxQty = 1000000) { InitializeComponent(); StockMaxQty = maxQty; Function = formFunction; switch (formFunction) { case FormFunction.AddToBasket: FormsProduct = new Product(product); AddToBasketForm(); break; case FormFunction.NewProduct: FormsProduct = product; NewProduct(); break; case FormFunction.ShoppingList: FormsProduct = new Product(product); ShoppingList(); break; default: break; } }
/*--- 建立新的問事表 ---*/ private void btnCreate_Click(object sender, EventArgs e) { string strPlace = btnSelectPlace.Text; if (strPlace == "選擇地點") { lblPlaceMsg.Visible = true; //顯示『必須選擇地點』 return; } string strDate = todayDate.Value.ToString("yyyyMMdd"); string tableName = strDate + strPlace; //建立問事表名稱 /*-- 確認資料庫中是否存在相同問事表 --*/ if (CheckTabelIsExist(tableName)) { FormFunction form = new FormFunction(); form.OpenFocusForm(new Message.WarningForm("資料表已經存在")); } else { askingTable.date = todayDate.Value; //設定建表日期 askingTable.placeName = strPlace; //設定建表地點 askingTable.CreateLabelandTable(tableName, false); this.Close(); // 關閉 NewTableForm askingTable.formFun.CloseMenu(); // 關閉HomeForm } }
private void WhichOneToSearchForm_Load(object sender, EventArgs e) { //視窗開啟位置 FormFunction.SetFormLocation(this); for (int index = 0; index < count; index++) { personalInfoView.Rows.Add(listInfo[index][1], listInfo[index][3], listInfo[index][2]); } personalInfoView.ClearSelection(); //清除資料列預選 }
/*--- 指定查詢的問事表 ---*/ private void btnSearch_Click(object sender, EventArgs e) { string content = txtInput.Text.Trim(); //取得去頭尾空白的輸入內容 if (content == "" || content == "輸入關鍵字") { FormFunction formFun = new FormFunction(); inWarningMsg.Visible = true; //顯示『必須輸入內容,才能做查詢』 return; } DateTime date; using (SqlConnection cn = new SqlConnection(Properties.Settings.Default.connectStr)) { string sqlStr = "select Asking_Tables.問事表名稱, Asking_Tables.問事日期, Asking_Place.地點名稱 " + "from Asking_Tables " + "inner join Asking_Place " + "on Asking_Tables.地點編號=Asking_Place.地點編號 " + "where Asking_Tables.問事表名稱 like N\'%" + content + "%\'"; SqlCommand cmd = new SqlCommand(sqlStr, cn); cn.Open(); SqlDataReader dr = cmd.ExecuteReader(); /*-- 是否有符合的資料存在 --*/ if (dr.HasRows) { tablesView.Rows.Clear(); //清空檢視表的資料 while (dr.Read()) { date = Convert.ToDateTime(dr["問事日期"]); string dateStr = date.ToString("yyyy年 MM月 dd日"); tablesView.Rows.Add(dr["問事表名稱"], dateStr, dr["地點名稱"]); } tablesView.Focus(); } else { dr.Close(); FormFunction formFun = new FormFunction(); formFun.OpenFocusForm(new WarningForm("查無所輸入的內容")); tablesView.Focus(); return; } } tablesView.ClearSelection(); //清除預選 }
/*--- 只能輸入字母、數字、控制鍵、空白鍵 ---*/ private void txtInput_KeyPress(object sender, KeyPressEventArgs e) { inWarningMsg.Visible = false; //隱藏『必須輸入內容,才能做查詢』 if (Char.IsLetterOrDigit(e.KeyChar) || Char.IsControl(e.KeyChar) || Char.IsWhiteSpace(e.KeyChar)) { e.Handled = false; } else { FormFunction formFun = new FormFunction(); formFun.OpenFocusForm(new WarningForm("只能輸入\"字母\"或\"數字\"")); e.Handled = true; } }
private void NewPersonalInfoForm_Load(object sender, EventArgs e) { /*--- 視窗開啟位置 ---------------- * *- if: 位置與 SignUpForm 相同 *-------------------------------*/ if (isFromTableForm == true) { FormFunction.FormLocationWithParent(this, parentForm); parentForm.Visible = false; //隱藏 SignUpForm } else { FormFunction.SetFormLocation(this); } }
/*--- 刪除整個問事表(包含問事紀錄) ---*/ private void btnDelete_Click(object sender, EventArgs e) { /*- 確認是否要刪除 -*/ Message.ConfirmForm confirm = new Message.ConfirmForm("該表的全部問事紀錄也會一並刪除哦"); FormFunction form = new FormFunction(); form.OpenFocusForm(confirm); /*- 確認要刪除 -*/ if (confirm.isOk) { isDeleted = true; DeleteAllAskingHistories(formTitle.Text); //刪除全部紀錄 DeleteAskingTable(formTitle.Text); //刪除問事表 this.Close(); } }
/*------ DataGridView 『tableView』 *-『tablesView_CellClic』:點擊該行資料,開啟編輯工具 *-『tablesView_ColumnHeaderMouseClick』:點擊標題欄時,不選資料列 *-----------------------------------------------------------------*/ private void tablesView_CellClick(object sender, DataGridViewCellEventArgs e) { int rowIndex = e.RowIndex; if (rowIndex >= 0) { string tableName = tablesView.Rows[rowIndex].Cells[0].Value.ToString(); FormFunction formFun = new FormFunction(); BrowseTablesEdit tablesEdit = new BrowseTablesEdit(askingTable, tableName); formFun.OpenFocusForm(tablesEdit); /*- 刪除問事表及其內容後,更新畫面顯示 -*/ if (tablesEdit.isDeleted) { ShowAllTables(); } } }
private void NewTableForm_Load(object sender, EventArgs e) { FormFunction.SetFormLocation(this); /*--- 設定元件的Radius ---*/ rt.SetControlRadius(btnSelectPlace, 16); /*--- 建立 PlaceList ---*/ CreatePlaceList(); /*--- 從資料庫撈出『地點名稱』,並加到 ListBox『placeList』中 ---*/ using (SqlConnection cn = new SqlConnection(Properties.Settings.Default.connectStr)) { string sqlStr = "select 地點名稱 from Asking_Place"; SqlCommand cmd = new SqlCommand(sqlStr, cn); cn.Open(); SqlDataReader dr = cmd.ExecuteReader(); while (dr.Read()) { dataCount++; //幾筆資料 placeList.Items.Add(dr["地點名稱"]); } dr.Close(); } /*--- 動態繪製 placeList的高度 ---*/ if (dataCount > 6) { placeList.Size = new Size(135, 26 * 6); } else { placeList.Size = new Size(135, 26 * dataCount); } rt.SetControlRadius(placeList, 16); }
/*--- 更新資料庫資料 *- 說明: 會依每個資料有無更動來做更新 *--------------------------------------------*/ private void UpdateDBData() { using (SqlConnection cn = new SqlConnection(Properties.Settings.Default.connectStr)) { cn.Open(); SqlCommand cmd; /*- 更新『姓名』-*/ if (nonSame_Name) { string sqlStr = "update Personal_Info set 姓名 = @name " + "where 聯絡編號 = @number"; cmd = new SqlCommand(sqlStr, cn); cmd.Parameters.Add(new SqlParameter("@name", SqlDbType.NVarChar)); cmd.Parameters.Add(new SqlParameter("@number", SqlDbType.Char)); cmd.Parameters["@name"].Value = newName; cmd.Parameters["@number"].Value = contactNum; cmd.ExecuteNonQuery(); } /*- 更新『聯絡電話』-*/ if (nonSame_PhomeNum) { string sqlStr = "update Personal_Info set 聯絡電話=@phoneNum " + "where 聯絡編號 = @number"; cmd = new SqlCommand(sqlStr, cn); cmd.Parameters.Add(new SqlParameter("@phoneNum", SqlDbType.NVarChar)); cmd.Parameters.Add(new SqlParameter("@number", SqlDbType.Char)); cmd.Parameters["@phoneNum"].Value = newPhoneNum; cmd.Parameters["@number"].Value = contactNum; cmd.ExecuteNonQuery(); } /*- 更新『居住地』-*/ if (nonSame_LivePlace) { string sqlStr = "update Personal_Info set 居住地=@livePlace " + "where 聯絡編號 = @number"; cmd = new SqlCommand(sqlStr, cn); cmd.Parameters.Add(new SqlParameter("@livePlace", SqlDbType.NVarChar)); cmd.Parameters.Add(new SqlParameter("@number", SqlDbType.Char)); cmd.Parameters["@livePlace"].Value = newLivePlace; cmd.Parameters["@number"].Value = contactNum; cmd.ExecuteNonQuery(); } /*- 更新『備註』-*/ if (nonSame_Rematks) { string sqlStr = "update Personal_Info set 備註=@remarks " + "where 聯絡編號 = @number"; cmd = new SqlCommand(sqlStr, cn); cmd.Parameters.Add(new SqlParameter("@remarks", SqlDbType.NVarChar)); cmd.Parameters.Add(new SqlParameter("@number", SqlDbType.Char)); cmd.Parameters["@remarks"].Value = newRemarks; cmd.Parameters["@number"].Value = contactNum; cmd.ExecuteNonQuery(); } } FormFunction form = new FormFunction(); form.OpenFocusForm(new Message.SuccessForm("聯絡資料更新完成")); }
private void PersonalHistoriesForm_Load(object sender, EventArgs e) { FormFunction.SetFormLocation(this); ShowAllAskingLog(contactNum); }
private void Window_MouseDown(object sender, MouseButtonEventArgs e) { FormFunction.MoveForm(sender, e, this); }
public void Exit(object sender, RoutedEventArgs e) { FormFunction.Exit(); }
private void OldPersonForm_Load(object sender, EventArgs e) { FormFunction.FormLocationWithParent(this, parentForm); parentForm.Visible = false; //隱藏SignUpForm (報名視窗) }
/*--- 修改 ---*/ private void btnComplete_Click(object sender, EventArgs e) { btnComplete.Focus(); //修改按鈕取得焦點 FormFunction form = new FormFunction(); Message.ConfirmForm confirmForm = new Message.ConfirmForm("是否確認要修改??"); form.OpenFocusForm(confirmForm); /*-- 取消修改 --*/ if (!confirmForm.isOk) { return; } /*-- 輸入的內容 --*/ newName = txtInName.Text.Trim(); newPhoneNum = txtPhone.Text.Trim(); newLivePlace = txtLivePlace.Text.Trim(); newRemarks = txtRemarks.Text.Trim(); /*-- 姓名或居住地不能為空,否則不進行修改 --*/ if (newName == "" || newLivePlace == "") { if (newName == "") { msgName.Visible = true; } if (newLivePlace == "") { msgPlace.Visible = true; } return; } /*-- 資料內容是否有更動 *- if: 無更動,不須更新資料庫 *- else: 有更動,須更新資料庫 *-----------------------------------*/ if (oldName == newName && oldPhoneNum == newPhoneNum && oldLivePlace == newLivePlace && oldRemarks == newRemarks) { form.OpenFocusForm(new Message.InfoForm("無任何內容更動")); } else { /*- 判斷哪個資料內容有更動 *第1個if :姓名 *第2個if :聯絡電話 *第3個if :居住地 *第4個if :備註 *---------------------------*/ if (oldName != newName) { nonSame_Name = true; //有更動 } } if (oldPhoneNum != newPhoneNum) { nonSame_PhomeNum = true; } if (oldLivePlace != newLivePlace) { nonSame_LivePlace = true; } if (oldRemarks != newRemarks) { nonSame_Rematks = true; } UpdateDBData(); //更新資料庫資料 } this.Close(); form.OpenToolForm(new PersonalInfoForm(parentForm, parentPan, formTitle, contactNum), parentPan); }
private void AddAskingPlaceForm_Load(object sender, EventArgs e) { FormFunction.SetFormLocation(this); }
private void ModifyPlaceNameForm_Load(object sender, EventArgs e) { FormFunction.SetFormLocation(this, 350, 42); lblOldName.Text = oldPlaceName; }
private void PersonalSignUpInfo_Load(object sender, EventArgs e) { FormFunction.SetFormLocation(this, 200, 10); }
private void EditAskingPlaceForm_Load(object sender, EventArgs e) { FormFunction.SetFormLocation(this); ShowAllPlace(); }
private void SignUpForm_Load(object sender, EventArgs e) { FormFunction.SetFormLocation(this); }
private void AddAskingContentForm_Load(object sender, EventArgs e) { /*- 視窗開啟位置 -*/ FormFunction.SetFormLocation(this, 200, 5); }
/*--- 視窗拖移功能 ---*/ private void formBar_MouseDown(object sender, MouseEventArgs e) { FormFunction.FormMobileFunction(this.Handle); }
/*--- 設定視窗開啟位置 ---*/ private void PersonalContactInfoForm_Load(object sender, EventArgs e) { FormFunction.SetFormLocation(this, parentForm, 25, 120); }