private void buttonIMPORT_Click(object sender, EventArgs e) { MyApp = new Excel.Application(); MyApp.Visible = false; MyBook = MyApp.Workbooks.Open(textBox1.Text); hhSheet = (Excel.Worksheet)MyBook.Sheets[1]; tonSheet = (Excel.Worksheet)MyBook.Sheets[2]; long hhCount = hhSheet.Cells.SpecialCells(Excel.XlCellType.xlCellTypeLastCell).Row; long khoCount = tonSheet.Cells.SpecialCells(Excel.XlCellType.xlCellTypeLastCell).Column; DataInstance.Instance().DBContext(); // HANG HOA for (int index = 2; index <= hhCount; index++) { System.Array MyValues = (System.Array)hhSheet.get_Range("A" + index.ToString(), "B" + index.ToString()).Cells.Value; DataInstance.Instance().DBContext().AddToHANG_HOA(new HANG_HOA { NAME = MyValues.GetValue(1, 1).ToString(), UNIT = MyValues.GetValue(1, 2).ToString(), }); } // KHO for (int index = 2; index <= khoCount; index++) { string MyValues = tonSheet.Cells[1, index].Value; DataInstance.Instance().DBContext().AddToKHOes(new KHO { NAME = MyValues, TYPE = MKho.KHO_HANG }); DataInstance.Instance().DBContext().SaveChanges(); for (int i = 2; i <= hhCount; i++) { long sl = long.Parse(tonSheet.Cells[i, index].Value.ToString()); long dongia = long.Parse(hhSheet.Cells[i, 3].Value.ToString()); DataInstance.Instance().DBContext().AddToNHAP_HANG(new NHAP_HANG { MAKHO = MKho.GetIDbyName(tonSheet.Cells[1, index].Value.ToString()), MANCC = -1, MAHH = MHangHoa.GetIDbyName(hhSheet.Cells[i, 1].Value.ToString()), SO_LUONG = sl, SL_CON_LAI = sl, DON_GIA_MUA = dongia, NGAY_NHAP = DateTime.Now.Date, CREATED_AT = DateTime.Now }); } } DataInstance.Instance().DBContext().SaveChanges(); MessageBox.Show("Cập nhật dữ liệu thành công\nVui lòng khởi động lại chương trình"); MyBook.Close(); MyApp.Quit(); MHeTHong.Set(MHeTHong.DATE, DateTime.Now.ToLongDateString()); Application.Exit(); }
private void buttonCONFIRM_Click(object sender, EventArgs e) { if (MHeTHong.Get(MHeTHong.MATKHAU) == textBox1.Text) { MHeTHong.Set(MHeTHong.DATE, DateTime.Now.ToShortDateString()); MessageBox.Show("ĐÃ CẬP NHẬT NGÀY THÁNG CỦA CHƯƠNG TRÌNH"); Application.Exit(); } else { MessageBox.Show("MẬT KHẨU KHÔNG ĐÚNG"); } }
private void buttonCHANGE_Click(object sender, EventArgs e) { if (MHeTHong.Get(MHeTHong.MATKHAU) != textBoxOLDPASS.Text) { MessageBox.Show("MẬT KHẨU CŨ KHÔNG ĐÚNG"); return; } if (textBoxNEWPASS.Text != textBoxRENEWPASS.Text) { MessageBox.Show("MẬT KHẨU MỚI KHÔNG GIỐNG NHAU"); return; } MHeTHong.Set(MHeTHong.MATKHAU, textBoxNEWPASS.Text); MessageBox.Show("ĐỔI MẬT KHẨU MỚI THÀNH CÔNG"); }
private void FMain_Load(object sender, EventArgs e) { DataInstance.Instance().DBContext(); DateTime now = DateTime.Now; DateTime last = Convert.ToDateTime(MHeTHong.Get(MHeTHong.DATE)); if (last.Date > now.Date) { FConfirm F = new FConfirm(); F.ShowDialog(); } else { MHeTHong.Set(MHeTHong.DATE, DateTime.Now.ToShortDateString()); } }
private void buttonPASS_Click(object sender, EventArgs e) { string pass = textBoxPASS.Text; string repass = textBoxREPASS.Text; if (pass != repass) { MessageBox.Show("Mật khẩu không trùng nhau"); return; } MHeTHong.Set(MHeTHong.MATKHAU, pass); DateTime now = new DateTime(); MHeTHong.Set(MHeTHong.DATE, now.ToLongDateString()); FImport F = new FImport(); F.Show(); this.Hide(); }