public ActionResult Edit(string makh) { if (!IsLogged()) { return(BackToLogin()); } KeHoachServices serKeHoach = new KeHoachServices(); TaiKhoanServices serTaiKhoan = new TaiKhoanServices(); StringBuilder sbHeHoach = new StringBuilder(); StringBuilder sbNguoiThucHien = new StringBuilder(); List <KeHoachForCombobox> lstKeHoachForCombobox = serKeHoach.SelectKeHoachForCombobox(new KeHoachModels()); var keHoachGroup = from p in lstKeHoachForCombobox where p.makehoachgoc == "0" select p; foreach (var item in keHoachGroup) { string strPref = ""; sbHeHoach.Append(string.Format("<option value='{0}'>{1}</option>", item.maKeHoach, item.noidungmuctieu)); var subItem = from p in lstKeHoachForCombobox where p.makehoachgoc == item.maKeHoach select p; if (subItem.Count() > 0) { sbHeHoach.Append(PrefAppendCombobox(lstKeHoachForCombobox, item.maKeHoach, ref strPref)); } } foreach (var item in serTaiKhoan.SelectTaiKhoanForCombobox(new M_TaiKhoan())) { sbNguoiThucHien.Append(string.Format("<option value='{0}'>{1}</option>", item.mataikhoan, item.hoten)); } ViewBag.keHoachs = sbHeHoach.ToString(); ViewBag.nguoiThucHiens = sbNguoiThucHien.ToString(); #region Set Param M_KeHoach param = new M_KeHoach(); string strMaKeHoach = "0"; if (makh != "0" && makh != null) { FunctionXML function = new FunctionXML(Functions.MapPath("~/Xml/Config/encryptionkeyEncodeLink.config")); strMaKeHoach = AES.DecryptText(makh, function.ReadXMLGetKeyEncrypt()); } if (GetPhongBanDonVi() != null) { param.madonvi = GetPhongBanDonVi().madonvi; param.makehoach = strMaKeHoach; } #endregion makehoach = strMaKeHoach; KeHoachServices service = new KeHoachServices(); List <KeHoachModels> lstResult = service.SelectRows(param); if (lstResult.Count > 0) { return(View(lstResult[0])); } return(View()); }
public ActionResult Create(KeHoachModels model) { //check login if (!IsLogged()) { return(BackToLogin()); } #region Set Param M_KeHoach clParamSuKien = new M_KeHoach(); clParamSuKien.noidungmuctieu = model.noidungmuctieu; clParamSuKien.ghichu = model.ghichu; clParamSuKien.makehoach = makehoach; clParamSuKien.ngaybatdau = FunctionsDateTime.ConvertDate(FunctionsDateTime.ConvertStringToDate(model.ngaybatdau)); clParamSuKien.ngayketthuc = FunctionsDateTime.ConvertDate(FunctionsDateTime.ConvertStringToDate(model.ngayketthuc)); clParamSuKien.nguoitao = Session["userid"].ToString(); clParamSuKien.nguoithuchien = model.nguoithuchien; clParamSuKien.makehoachgoc = model.makehoachgoc; clParamSuKien.tytrong = model.tytrong; clParamSuKien.chitieunam = model.chitieunam; clParamSuKien.ngaytao = "GETDATE()"; clParamSuKien.nguoihieuchinh = Session["userid"].ToString(); clParamSuKien.ngayhieuchinh = "GETDATE()"; if (GetPhongBanDonVi() != null) { clParamSuKien.madonvi = GetPhongBanDonVi().madonvi; } #endregion KeHoachServices services = new KeHoachServices(); if (makehoach.Trim() == "") { services.InsertRow(clParamSuKien, Session["manhansu"].ToString()); } else { services.UpdateRow(clParamSuKien); } makehoach = ""; return(RedirectToAction("Index", "Milestones")); }
public ActionResult Create() { if (!IsLogged()) { return(BackToLogin()); } KeHoachServices serKeHoach = new KeHoachServices(); TaiKhoanServices serTaiKhoan = new TaiKhoanServices(); StringBuilder sbHeHoach = new StringBuilder(); StringBuilder sbNguoiThucHien = new StringBuilder(); List <KeHoachForCombobox> lstKeHoachForCombobox = serKeHoach.SelectKeHoachForCombobox(new KeHoachModels()); var keHoachGroup = from p in lstKeHoachForCombobox where p.makehoachgoc == "0" select p; foreach (var item in keHoachGroup) { string strPref = ""; sbHeHoach.Append(string.Format("<option value='{0}'>{1}</option>", item.maKeHoach, item.noidungmuctieu)); var subItem = from p in lstKeHoachForCombobox where p.makehoachgoc == item.maKeHoach select p; if (subItem.Count() > 0) { sbHeHoach.Append(PrefAppendCombobox(lstKeHoachForCombobox, item.maKeHoach, ref strPref)); } } foreach (var item in serTaiKhoan.SelectTaiKhoanForCombobox(new M_TaiKhoan())) { sbNguoiThucHien.Append(string.Format("<option value='{0}'>{1}</option>", item.mataikhoan, item.hoten)); } ViewBag.keHoachs = sbHeHoach.ToString(); ViewBag.nguoiThucHiens = sbNguoiThucHien.ToString(); return(View()); }
public JsonResult SelectRows(KeHoachModels model) { //lay phong ban don vi #region Set Param M_KeHoach param = new M_KeHoach(); string strMaKeHoach = "0"; if (model.makehoach != "0") { FunctionXML function = new FunctionXML(Functions.MapPath("~/Xml/Config/encryptionkeyEncodeLink.config")); strMaKeHoach = AES.DecryptText(model.makehoach, function.ReadXMLGetKeyEncrypt()); } if (GetPhongBanDonVi() != null) { param.madonvi = GetPhongBanDonVi().madonvi; param.makehoachgoc = strMaKeHoach; } #endregion KeHoachServices service = new KeHoachServices(); List <KeHoachModels> lstResult = service.SelectRows(param); StringBuilder sbResult = new StringBuilder(); StringBuilder sbRows = new StringBuilder(); if (lstResult.Count > 0) { string strSTT = ""; int i = 1; foreach (var item in lstResult) { bool isPlus = false; param.makehoachgoc = item.makehoach; if (service.CountRows(param) > 0) { isPlus = true; } if (model.stt == "0") { strSTT = i.ToString(); } else { strSTT = string.Format("{0}.{1}", model.stt, i); } sbRows.Append(PrepareDataJson(item, strSTT, isPlus)); i++; } if (sbRows.Length > 0) { sbRows.Remove(sbRows.Length - 1, 1); } } sbResult.Append("{"); sbResult.Append("\"isHeader\":\"" + "111" + "\","); sbResult.Append("\"Pages\":\"" + "212" + "\","); if (model.makehoach != "0") { sbResult.Append("\"SubRow\":\"" + "true" + "\","); sbResult.Append("\"RowID\":\"" + model.makehoach + "\","); } sbResult.Append("\"data\":[" + sbRows.ToString() + "]"); sbResult.Append("}"); return(Json(sbResult.ToString(), JsonRequestBehavior.AllowGet)); }