private void datag1_CellClick(object sender, DataGridViewCellEventArgs e) { try { var con = ketnoisqlite.Khoitao(); var conkm = ketnoikhuyenmai.Khoitao(); hamtao ham = new hamtao(); DataGridViewRow roww = datag1.Rows[e.RowIndex]; string matong = roww.Cells[0].Value.ToString(); lbmatong.Text = matong; string[] laygiatri = conkm.laythongtinkhuyenmai(matong); string[] ketqua = new string[2]; if (laygiatri != null) { ketqua = ham.tinhToan(laygiatri[0], laygiatri[1]); lbgiachot.Text = ketqua[0]; lbphantram.Text = ketqua[1]; // Laymota(matong); doiMau_Phatam(); // chay ham doi mau } else { lbgiachot.Text = "-"; lbphantram.Text = "-"; //lbmota.Text = ""; } } catch (Exception) { return; } }
//void Laymota(string matong) //{ // try // { // string[] laythongtinMota = null; // //try // //{ // // var conmysql = ketnoi.Khoitao(); // // //laythongtinMota = conmysql.laythongtinMota(matong); // //} // //catch (Exception) // //{ // // laythongtinMota = null; // //} // if (laythongtinMota[0] != null || laythongtinMota[1] != null) // { // lbmota.Text = "\" " + laythongtinMota[0] + " - " + laythongtinMota[1] + "\""; // } // } // catch (Exception) // { // lbmota.Text = "^--^"; // return; // } //} private void txtbarcode_KeyDown(object sender, KeyEventArgs e) { try { if (e.KeyCode == Keys.Enter) { if (!string.IsNullOrEmpty(txtbarcode.Text)) { var con = ketnoisqlite.Khoitao(); var conkm = ketnoikhuyenmai.Khoitao(); hamtao ham = new hamtao(); string matong = con.laymasp(txtbarcode.Text); if (matong == null) { NotificationHts("Lỗi\nMã này chưa có trong danh mục Khuyến Mãi"); txtbarcode.Clear(); txtbarcode.Focus(); return; } lbmatong.Text = matong; string[] laygiatri = conkm.laythongtinkhuyenmai(matong); string[] ketqua = new string[2]; if (laygiatri[0] != null || laygiatri[1] != null) { ketqua = ham.tinhToan(laygiatri[0], laygiatri[1]); lbgiachot.Text = ketqua[0]; lbphantram.Text = ketqua[1]; //Laymota(matong); doiMau_Phatam(); // chay ham doi mau chenBang(); // them ma moi vao bang hien thi } else { lbgiachot.Text = "Nguyên giá"; lbphantram.Text = "-"; //lbmota.Text = "^-^"; chenBang(); lbgiachot.ForeColor = Color.DimGray; lbphantram.ForeColor = Color.DimGray; } txtbarcode.Clear(); txtbarcode.Focus(); } } } catch (Exception) { NotificationHts("Lỗi\n"); return; } }