protected void btnSuaDongYClick(object sender, DirectEventArgs e) { try { //if (SingleGridPanel1.GetSelectedRecordIDs().Count() > 1) //{ // X.MessageBox.Alert("Cảnh báo", "Bạn chỉ có thể chọn một nhân viên !").Show(); // return; //} // Regex myRegex = new Regex("/[0-9A-Za-z\;]/"); //myRegex.IsMatch(preg_match("/^([1-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])(\.([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])){3}$/", "fsdfsd"); if (txtSua.Text.LastIndexOf(';') == txtSua.Text.Length - 1) { txtSua.Text = txtSua.Text.Remove(txtSua.Text.LastIndexOf(';')); } foreach (var item in SingleGridPanel1.GetSelectedRecordIDs()) { new HoSoController().UpdateMaChamCong(item, txtSua.Text); } Dialog.ShowNotification("Thông báo", "Cập nhật thành công !"); SingleGridPanel1.GetGridPanel().Reload(); wdSua.Hide(); } catch (Exception ex) { X.MessageBox.Alert("Có lỗi xảy ra", ex.Message).Show(); } }
protected void btnSuDungMaNhanVien_Click(object sender, DirectEventArgs e) { try { string str = ""; if (e.ExtraParams["SelectedEmployees"] != "") { foreach (var item in SingleGridPanel1.GetSelectedRecordIDs()) { str += item + ","; } if (!string.IsNullOrEmpty(str)) { str = "," + str; } DataController.DataHandler.GetInstance().ExecuteNonQuery("ChamCong_SuDungMaCanBoLamMaChamCong", "@maCbStr", "@maDonVi", str, ""); } else { DataController.DataHandler.GetInstance().ExecuteNonQuery("ChamCong_SuDungMaCanBoLamMaChamCong", "@maCbStr", "@maDonVi", str, "," + hdfStringMaDonVi.Text + ","); } SingleGridPanel1.GetGridPanel().Reload(); wdSuDungMaNhanVien.Hide(); } catch (Exception ex) { X.MessageBox.Alert("Có lỗi xảy ra", ex.Message).Show(); } }
protected void ExportExcelClick(object sender, DirectEventArgs e) { string sourceFile = Server.MapPath("") + "\\FileMau\\Ma cham cong mau.xls"; string destination = Server.MapPath("") + "\\File\\Ma cham cong export.xls"; File.Copy(sourceFile, destination, true); System.Data.OleDb.OleDbConnection MyConnection; System.Data.OleDb.OleDbCommand myCommand = new System.Data.OleDb.OleDbCommand(); string sql = null; MyConnection = new System.Data.OleDb.OleDbConnection("provider=Microsoft.Jet.OLEDB.4.0;Data Source='" + destination + "';Extended Properties=Excel 8.0;"); MyConnection.Open(); myCommand.Connection = MyConnection; int dem = 0; if (radExpTatCa.Checked == true) { List <HoSoInfo> listhoso = new HoSoController().GetHoSoMaChamCong(Session["MaDonVi"].ToString(), new List <string>(), false); foreach (var item in listhoso) { dem++; sql = @"Insert into [Sheet1$] values('" + item.MACB + "','" + item.HOTEN + "','" + item.PHONGBAN + "','" + item.MaChamCong + "')"; myCommand.CommandText = sql; myCommand.ExecuteNonQuery(); } } if (radExpBoPhan.Checked == true) { List <HoSoInfo> listhoso = new HoSoController().GetHoSoMaChamCong(SingleGridPanel1.GetMaDonVi(), new List <string>(), false); foreach (var item in listhoso) { dem++; sql = @"Insert into [Sheet1$] values('" + item.MACB + "','" + item.HOTEN + "','" + item.PHONGBAN + "','" + item.MaChamCong + "')"; myCommand.CommandText = sql; myCommand.ExecuteNonQuery(); } } HoSoController hsc = new HoSoController(); if (radExpChon.Checked == true) { foreach (var item in new HoSoController().GetHoSoMaChamCong(Session["MaDonVi"].ToString(), SingleGridPanel1.GetSelectedRecordIDs() ?? new List <string>(), true)) { dem++; sql = @"Insert into [Sheet1$] values('" + item.MACB + "','" + item.HOTEN + "','" + item.PHONGBAN + "','" + item.MaChamCong + "')"; myCommand.CommandText = sql; myCommand.ExecuteNonQuery(); } } MyConnection.Close(); Dialog.ShowNotification("Thông báo", "Đã xuất thông tin của " + dem.ToString() + " cán bộ thành công"); Response.Clear(); Response.ContentType = "application/octet-stream"; Response.AddHeader("Content-Disposition", "attachment; filename=" + "MaChamCongExport.xls"); Response.WriteFile(destination); Response.End(); wdExport.Hide(); }