private void btn_Add_Click(object sender, EventArgs e) { if (!this.txb_Name_Add.Text.Equals("")) { if (this.cbb_HotKey_Add.SelectedIndex != 0) { foreach (DataRow dr in MatHangManager.s_DanhSachMatHang.Rows) { string a = dr["HotKey"].ToString(); if (int.Parse(dr["HotKey"].ToString()) == this.cbb_HotKey_Add.SelectedIndex) { string value = dr["Price"].ToString(); int ivalue; bool isValidValue = int.TryParse(value, NumberStyles.Integer | NumberStyles.AllowThousands, CultureInfo.GetCultureInfo("en-US"), out ivalue); SqlHelper.UpdateMatHang(int.Parse(dr["ID"].ToString()), dr["Name"].ToString(), ivalue, 0); } } } SqlHelper.InsertMatHang(this.txb_Name_Add.Text, (int)this.numeric_Price_Add.Value, this.cbb_HotKey_Add.SelectedIndex); MatHangManager.refresh(); this.dataGridView2.DataSource = MatHangManager.s_DanhSachMatHang; } }
private void btn_SaveEdit_Click(object sender, EventArgs e) { if (this.cbb_HotKey_Edit.SelectedIndex != 0) { foreach (DataRow dr in MatHangManager.s_DanhSachMatHang.Rows) { //string a = dr["HotKey"].ToString(); if (int.Parse(dr["HotKey"].ToString()) == this.cbb_HotKey_Edit.SelectedIndex) { string value = dr["Price"].ToString(); int ivalue; bool isValidValue = int.TryParse(value, NumberStyles.Integer | NumberStyles.AllowThousands, CultureInfo.GetCultureInfo("en-US"), out ivalue); SqlHelper.UpdateMatHang(int.Parse(dr["ID"].ToString()), dr["Name"].ToString(), ivalue, 0); } } } SqlHelper.UpdateMatHang(int.Parse(this.dataGridView2.CurrentRow.Cells["ID"].Value.ToString()), this.txb_Name_Edit.Text, (int)this.numeric_Price_Edit.Value, this.cbb_HotKey_Edit.SelectedIndex); MatHangManager.refresh(); this.dataGridView2.DataSource = MatHangManager.s_DanhSachMatHang; this.Edit_container.Visible = false; this.Add_container.Visible = true; }
public void TXSMH_closed(object sender, FormClosedEventArgs e) { MatHangManager.refresh(); this.dataGridView2.DataSource = MatHangManager.s_DanhSachMatHang; dataGridView2.ClearSelection(); this.dataGridView2.Rows[0].Selected = true; this.m_selected_ID_MH = int.Parse(dataGridView2.SelectedRows[0].Cells["ID"].Value.ToString()); this.lbl_MatHang.Text = dataGridView2.SelectedRows[0].Cells["Name"].Value.ToString(); }
private void btn_Delete_Click(object sender, EventArgs e) { DialogResult dialogResult = MessageBox.Show("Bạn có chắc chắn muốn xóa mặt hàng.\nDữ liệu sau khi xóa sẽ không thể khôi phục được.", "Cảnh báo", MessageBoxButtons.YesNo); if (dialogResult == DialogResult.Yes) { //do something int ID = int.Parse(this.dataGridView2.CurrentRow.Cells["ID"].Value.ToString()); SqlHelper.DeleteMatHang(ID); MatHangManager.refresh(); this.dataGridView2.DataSource = MatHangManager.s_DanhSachMatHang; MessageBox.Show("Xóa mặt hàng thành công."); } else if (dialogResult == DialogResult.No) { //do something else } }
private void btn_TimKiemMatHang_Click(object sender, EventArgs e) { if (txb_TimKiemMatHang.Text.Equals("")) { this.dataGridView2.DataSource = MatHangManager.s_DanhSachMatHang; dataGridView2.ClearSelection(); this.dataGridView2.Rows[0].Selected = true; this.m_selected_ID_MH = int.Parse(dataGridView2.SelectedRows[0].Cells["ID"].Value.ToString()); this.lbl_MatHang.Text = dataGridView2.SelectedRows[0].Cells["Name"].Value.ToString(); } else { DataTable searchMatHang = MatHangManager.getMatHangByName(this.txb_TimKiemMatHang.Text); this.dataGridView2.DataSource = searchMatHang; dataGridView2.ClearSelection(); if (searchMatHang.Rows.Count > 0) { this.dataGridView2.Rows[0].Selected = true; this.m_selected_ID_MH = int.Parse(dataGridView2.SelectedRows[0].Cells["ID"].Value.ToString()); this.lbl_MatHang.Text = dataGridView2.SelectedRows[0].Cells["Name"].Value.ToString(); } } }
private void Scale_Load(object sender, EventArgs e) { SetSaveButtonIcon(); SetPrintButtonIcon(); //Get all available printers and add them to the combo box //foreach (String printer in PrinterSettings.InstalledPrinters) //{ // Settings.s_printer_name = printer.ToString(); // break; //} //MessageBox.Show(Settings.s_printer_name); if (File.Exists("personalized.ini")) { Settings.Read_personalized(); this.lbl_App_Name.Text = Uri.UnescapeDataString(Settings.personalized.s_app_name); this.lbl_Scale_Com_NameA.Text = Uri.UnescapeDataString(Settings.personalized.s_com_name_A); this.lbl_Detail_COMA.Text = Uri.UnescapeDataString(Settings.personalized.s_com_detail_A) + Uri.UnescapeDataString(Settings.personalized.s_com_detail_A_2); this.lbl_Scale_Com_NameB.Text = Uri.UnescapeDataString(Settings.personalized.s_com_name_B); this.lbl_Detail_COMB.Text = Uri.UnescapeDataString(Settings.personalized.s_com_detail_B) + Uri.UnescapeDataString(Settings.personalized.s_com_detail_B_2);; } else { this.lbl_App_Name.Text = "HỆ THỐNG CÂN KỸ THUẬT CƯỜNG THỊNH PHÁT"; this.lbl_Scale_Com_NameA.Text = "CTY TNHH CÂN ĐIỆN TỬ CƯỜNG THỊNH PHÁT CTPS ELECTRONIC SCALE CO., LTD."; this.lbl_Detail_COMA.Text = "Đ/c: 603 QL13 - P.Hiệp Bình Chánh - Q.Thủ Đức - TP.HCM.\n" + "ĐT: (028) 66.544.865 – 0977.975.865 – 0903.665.012 //Kế Toán: 0167 951 5828.\n" + "Giờ làm việc: 8:00h – 17:00h.\n" + "Sau 17:00h Liên hệ: (028) 66.544.865."; this.lbl_Scale_Com_NameB.Text = "CTY TNHH CÂN ĐIỆN TỬ CƯỜNG THỊNH PHÁT CTPS ELECTRONIC SCALE CO., LTD."; this.lbl_Detail_COMB.Text = "Đ/c: 603 QL13 - P.Hiệp Bình Chánh - Q.Thủ Đức - TP.HCM.\n" + "ĐT: (028) 66.544.865 – 0977.975.865 – 0903.665.012 //Kế Toán: 0167 951 5828.\n" + "Giờ làm việc: 8:00h – 17:00h.\n" + "Sau 17:00h Liên hệ: (028) 66.544.865."; int subA = lbl_Detail_COMA.Text.Length / 2; int subB = lbl_Detail_COMB.Text.Length / 2; string detailA1 = lbl_Detail_COMA.Text.Substring(0, subA); string detailA2 = lbl_Detail_COMA.Text.Substring(subA, lbl_Detail_COMA.Text.Length - detailA1.Length); string detailB1 = lbl_Detail_COMB.Text.Substring(0, subB); string detailB2 = lbl_Detail_COMB.Text.Substring(subB, lbl_Detail_COMB.Text.Length - detailB1.Length); Settings.personalized.s_app_name = Uri.EscapeDataString(this.lbl_App_Name.Text); Settings.personalized.s_com_name_A = Uri.EscapeDataString(this.lbl_Scale_Com_NameA.Text); Settings.personalized.s_com_detail_A = Uri.EscapeDataString(detailA1); Settings.personalized.s_com_detail_A_2 = Uri.EscapeDataString(detailA2); Settings.personalized.s_com_name_B = Uri.EscapeDataString(this.lbl_Scale_Com_NameB.Text); Settings.personalized.s_com_detail_B = Uri.EscapeDataString(detailB1); Settings.personalized.s_com_detail_B_2 = Uri.EscapeDataString(detailB2); Settings.Write_personalized(); } //string[] listformat = CultureInfo.CurrentUICulture.DateTimeFormat.GetAllDateTimePatterns(); //string printt = ""; //for (int i = 0; i < listformat.Length; i++) //{ // printt += " "; // printt += listformat[i]; //} //MessageBox.Show(printt); SqlHelper.get10Values(); this.dataGridView1.DataSource = SqlHelper.s_table_10Models; datagridview1_setHeaderName(); this.logo.Image = Image.FromFile("./logo.png"); //this.lbl_App_Name.Text = m_com_name; //this.lbl_Scale_Com_NameA.Text = "CTY TNHH CÂN ĐIỆN TỬ CƯỜNG THỊNH PHÁT CTPS ELECTRONIC SCALE CO., LTD."; //this.lbl_Detail_COMB.Text = "Đ/c: 603 QL13 - P.Hiệp Bình Chánh - Q.Thủ Đức - TP.HCM."; //this.lbl_contact1.Text = "ĐT: (028) 66.544.865 – 0977.975.865 – 0903.665.012 // Kế Toán: 0167 951 5828"; //this.lbl_detail.Text = "Giờ làm việc: 8:00h – 17:00h."; //this.lbl_detail2.Text = "Sau 17:00h Liên hệ: (028) 66.544.865."; MatHangManager.init(); this.dataGridView2.DataSource = MatHangManager.s_DanhSachMatHang; this.dataGridView2.Columns["Name"].HeaderText = "Tên"; this.dataGridView2.Columns["Price"].HeaderText = "Giá"; this.dataGridView2.Columns["HotKey"].HeaderText = "Phím tắt"; this.dataGridView2.Columns["ID"].Visible = false; this.m_selected_ID_MH = int.Parse(dataGridView2.SelectedRows[0].Cells["ID"].Value.ToString()); this.lbl_MatHang.Text = dataGridView2.SelectedRows[0].Cells["Name"].Value.ToString(); //Tải lên danh sách mặt hàng }