public ActionResult Create(HolidayMaster holiday) { SetSessionVariables(); holiday.ClientID = GetSessionObject().ClientID.Value; using (var client = new HttpClient()) { client.BaseAddress = new Uri(Common.Instance.ApiHolidayControllerName); //HTTP POST var postTask = client.PostAsJsonAsync <HolidayMaster>(Common.Instance.ApiHolidayAddEditHoliday, holiday); postTask.Wait(); var result = postTask.Result; if (result.IsSuccessStatusCode) { //var rs = result.Content.ReadAsAsync<ClientMaster>(); ////return RedirectToAction("Index"); //NewClient = rs.Result; var rs = result.Content.ReadAsAsync <bool>().Result; } } return(RedirectToAction("Index")); }
public List <HolidayMaster> FetchHolidayMasterData() { try { List <HolidayMaster> HolidayMasterList = new List <HolidayMaster>(); DataSet dsResult = new DataSet(); dsResult = General.ExecuteDataSet("FETCH_HOLIDAY_DETAILS"); if (dsResult != null && dsResult.Tables.Count > 0 && dsResult.Tables[0].Rows.Count > 0) { foreach (DataRow dr in dsResult.Tables[0].Rows) { HolidayMaster obj = new HolidayMaster(); obj.ID = Convert.ToInt32(dr["ID"]); obj.Version = Convert.ToInt32(dr["VERSION"]); obj.HolidayDate = Convert.ToDateTime(dr["HOLIDAY_DATE"]); obj.Reason = Convert.ToString(dr["REASON"]); HolidayMasterList.Add(obj); } } var HolidayMasterListData = HolidayMasterList.ToList(); return(HolidayMasterListData); } catch (Exception ex) { UserMaster objUserMaster = new UserMaster(); objUserMaster = (UserMaster)Session["LoggedInUser"]; LogError(ex.Message, ex.StackTrace, "UnderlyingCreationController", "FetchHolidayMaster", objUserMaster.UserID); return(null); } }
public ActionResult Edit(int HolidayID, DateTime HolidayDate, string HolidayDetails) { HolidayMaster holiday = new HolidayMaster(); holiday.ClientID = GetSessionObject().ClientID.Value; holiday.HolidayID = HolidayID; holiday.HolidayDate = HolidayDate; holiday.HolidayDetails = HolidayDetails; SetSessionVariables(); //using (var client = new HttpClient()) //{ // client.BaseAddress = new Uri(Common.Instance.ApiHolidayControllerName); // //HTTP GET // var responseTask = client.PostAsJsonAsync<HolidayMaster>(Common.Instance.ApiHolidayAddEditHoliday, holiday); // responseTask.Wait(); // var result = responseTask.Result; // if (result.IsSuccessStatusCode) // { // var readTask = result.Content.ReadAsAsync<bool>(); // readTask.Wait(); // var rs = readTask.Result; // } //} return(View(holiday)); }
public ActionResult Create() { HolidayMaster holiday = new HolidayMaster(); SetSessionVariables(); return(View(holiday)); }
private void SetObjectInfo(HolidayMaster _objHolidayMaster) { _objHolidayMaster.FinancialYear = ddlFinYear.SelectedValue; _objHolidayMaster.HoliDays = txtHoliday.Text; _objHolidayMaster.EnglishMonth = ddlMonth.SelectedValue; _objHolidayMaster.EnglishDate = Convert.ToInt32(ddlDate.SelectedValue); _objHolidayMaster.SakaMonth = ddlSakaMonth.SelectedValue; _objHolidayMaster.SakaDate = Convert.ToInt32(ddlSakaDate.SelectedValue); _objHolidayMaster.HoliDays_Day = ddlWeekDay.SelectedValue; _objHolidayMaster.Holidays_Type = ddlHoliDayNature.SelectedValue; _objHolidayMaster.CreatedBy = Session["LoginId"].ToString(); }
public static string[] GetCompletionListHolidayName(string prefixText, int count, string contextKey) { HolidayMaster objHolidayMaster = new HolidayMaster(); DataTable dt = new DataView(objHolidayMaster.GetHolidayMaster(HttpContext.Current.Session["CompId"].ToString()), "Holiday_Name like '" + prefixText.ToString() + "%'", "", DataViewRowState.CurrentRows).ToTable(); string[] txt = new string[dt.Rows.Count]; for (int i = 0; i < dt.Rows.Count; i++) { txt[i] = dt.Rows[i]["Holiday_Name"].ToString(); } return(txt); }
public Int32 DeleteHolidayMaster(string HolidayID, string HolidayName, string HolidayDate) { HolidayMaster hMaster = new HolidayMaster(); if (ValidateSession()) { } if (HolidayID != null) { Int32 IsActive = 0; ManageHoliday(HolidayID, HolidayName, HolidayDate, IsActive); } return(1); }
private void AssignVariableTOControl(HolidayMaster _objHolidayMaster) { if (_objHolidayMaster != null) { ddlFinYear.SelectedValue = _objHolidayMaster.FinancialYear; ddlHoliDayNature.SelectedValue = _objHolidayMaster.Holidays_Type; ddlMonth.SelectedValue = _objHolidayMaster.EnglishMonth.Split('-')[0]; ddlDate.SelectedValue = _objHolidayMaster.EnglishDate.ToString(); ddlSakaMonth.SelectedValue = _objHolidayMaster.SakaMonth; ddlSakaDate.SelectedValue = _objHolidayMaster.SakaDate.ToString(); ddlWeekDay.SelectedValue = _objHolidayMaster.HoliDays_Day; txtHoliday.Text = _objHolidayMaster.HoliDays; } }
public ActionResult HolidayMaster(int?holidayID) { HolidayMaster hMaster = new HolidayMaster(); if (ValidateSession()) { } if (holidayID != null) { List <HolidayMaster> hm = FetchHolidayMasterData(); var hMasterResult = hm.FirstOrDefault(h => h.ID.Equals(holidayID)); hMaster = hMasterResult; } return(View(hMaster)); }
public async Task <ActionResult <bool> > AddEditHoliday([FromBody] HolidayMaster holiday) { bool result = true; using (var trans = _context.Database.BeginTransaction()) { try { try { if (holiday.HolidayID > 0) { _context.Entry(holiday).State = EntityState.Modified; } else { _context.Holidays.Add(holiday); } await _context.SaveChangesAsync(); trans.Commit(); } catch (DbUpdateConcurrencyException err) { trans.Rollback(); result = false; } } catch (Exception err) { trans.Rollback(); result = false; } } return(result); }
public string UpdateHolidayDetails(HolidayMaster obj) { DALCommon dal = new DALCommon(ConStr); return(dal.UpdateHolidayDetails(obj)); }
public ActionResult HolidayMaster(string Command, HttpPostedFileBase file) { if (ValidateSession()) { } FetchUploadFileMasterList(); List <UploadFileMaster> UploadFileMasterList = (List <UploadFileMaster>)Session["UploadFileMasterList"]; HolidayMaster hMaster = new HolidayMaster(); if (Command == "PDDownload") { UploadFileMaster objUploadFileMaster = UploadFileMasterList.Find( delegate(UploadFileMaster oUploadFileMaster) { return(oUploadFileMaster.UploadTypeCode == "HM"); }); string strFilePath = System.Web.HttpContext.Current.Server.MapPath(objUploadFileMaster.TemplateFileName); if (System.IO.File.Exists(strFilePath)) { FileInfo fileinfo = new FileInfo(strFilePath); Response.Clear(); Response.ClearHeaders(); Response.ClearContent(); Response.AddHeader("content-disposition", "attachment; filename=" + Path.GetFileName(strFilePath)); Response.AddHeader("Content-Type", "application/Excel"); Response.ContentType = "application/vnd.xls"; Response.AddHeader("Content-Length", fileinfo.Length.ToString()); Response.WriteFile(fileinfo.FullName); Response.End(); } } if (Command == "PDUpload") { if (file != null && file.ContentLength > 0) { UploadFileMaster objUploadFileMaster = UploadFileMasterList.Find(delegate(UploadFileMaster oUploadFileMaster) { return(oUploadFileMaster.UploadTypeCode == "HM"); }); string strFilePath = System.Web.HttpContext.Current.Server.MapPath("~/Uploads/"); string strFileName = Path.GetFileNameWithoutExtension(file.FileName) + DateTime.Now.ToString("dd_mmm_yyyy_hh_mm"); string strExtension = Path.GetExtension(file.FileName); strFilePath += strFileName + strExtension; file.SaveAs(strFilePath); FileInfo newFile = new FileInfo(strFilePath); string strSourceColumn = objUploadFileMaster.SourceColumn; string[] arrSourceColumn = null; if (strSourceColumn != "") { arrSourceColumn = strSourceColumn.Split('|'); } DataTable dtData = new DataTable(); for (int i = 0; i < arrSourceColumn.Length; i++) { dtData.Columns.Add(arrSourceColumn[i]); } string strDestinationColumn = objUploadFileMaster.DestinationColumn; string[] arrDestinationColumn = null; if (strDestinationColumn != "") { arrDestinationColumn = strDestinationColumn.Split('|'); } string strTableName = objUploadFileMaster.TableName; using (ExcelPackage xlPackage = new ExcelPackage(newFile)) { ExcelWorksheet worksheet = xlPackage.Workbook.Worksheets[objUploadFileMaster.SheetName]; string strVersion = worksheet.Cell(1, 2).Value.Trim(); if (strVersion == "") { strVersion = "0"; } DataRow drNew; for (int iRow = 2; iRow < 36; iRow++) { if (Convert.ToString(worksheet.Cell(iRow, 1).Value) != "") { drNew = dtData.NewRow(); var Reason = worksheet.Cell(iRow, 1).Value; var Holiday_Date = DateTime.FromOADate(double.Parse(worksheet.Cell(iRow, 2).Value)); drNew["REASON"] = Reason;//worksheet.Cell(iRow, 1).Value; drNew["HOLIDAY_DATE"] = Convert.ToDateTime(Holiday_Date); drNew["VERSION"] = 1; drNew["ISACTIVE"] = 1; dtData.Rows.Add(drNew); } else { break; } } } string strMyConnection = Convert.ToString(System.Configuration.ConfigurationManager.ConnectionStrings["SP_PRICINGConnectionString"]); if (arrSourceColumn != null && arrDestinationColumn != null && arrSourceColumn.Length == arrDestinationColumn.Length) { using (SqlBulkCopy bulkCopy = new SqlBulkCopy(strMyConnection)) { bulkCopy.DestinationTableName = strTableName; for (int i = 0; i < arrSourceColumn.Length; i++) { bulkCopy.ColumnMappings.Add(arrSourceColumn[i], arrDestinationColumn[i]); } bulkCopy.WriteToServer(dtData); } blnUploadStatus = true; } else { blnUploadStatus = false; } if (blnUploadStatus) { ViewBag.Message = "Imported successfully"; } return(View(hMaster)); } } return(View(hMaster)); }