public ActionResult OtherReceiptesUpload(HttpPostedFileBase file) { DataSet ds = new DataSet(); string errMessage = string.Empty; if (Request.Files["uploadreceipt"].ContentLength > 0) { string fileExtension = System.IO.Path.GetExtension(Request.Files["uploadreceipt"].FileName); if (fileExtension != ".xls" && fileExtension != ".xlsx") { errMessage = "Please upload a valid excel file."; } else { try { ds = ConvertExcelToDataSet(); if (ds.Tables.Count < 1) { errMessage = "Please upload a valid excel file."; } } catch (Exception ex) { errMessage = "Please upload a valid excel file."; } } } else { errMessage = "Please upload a excel file"; } List <UploadErrorEntries> errAl = new List <UploadErrorEntries>(); if (string.IsNullOrWhiteSpace(errMessage)) { DataTable dtOtherReciept = ds.Tables[0]; objUploadValidateInfo = _groupOtherReceiptService.GetGroupOtherRecieptValidateInfo(GroupInfo.GroupID); bool isValid = ValidateOtherRecieptUpload(dtOtherReciept, ref errAl); if (isValid) { List <GroupOtherRecieptDto> lstGroupOtherReceiptDto = ConvertGroupOtherRecieptDataTableToList(dtOtherReciept); foreach (var obj in lstGroupOtherReceiptDto) { ResultDto resultDto = new ResultDto(); int GroupId = GroupInfo.GroupID; bool isContra = false; resultDto = _groupOtherReceiptService.Insert(obj, GroupId, isContra); obj.VoucherNumber = resultDto.ObjectCode; obj.AccountMasterID = resultDto.ObjectId; } } } bool isSucess = false; if (errMessage == string.Empty && errAl.Count < 1) { isSucess = true; } ViewBag.isSucess = isSucess; ViewBag.ErrorMessage = errMessage; ViewBag.DataErrorsList = errAl; return(View()); }
public GroupOtherRecieptUploadValidateInfo GetGroupOtherRecieptValidateInfo(int groupId) { SqlConnection con = new SqlConnection(DBConstants.MFIS_CS); GroupOtherRecieptUploadValidateInfo obj = new GroupOtherRecieptUploadValidateInfo(); try { SqlCommand cmd = new SqlCommand("uspGroupOtherRecieptUploadValiateInfo", con); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@GroupId", groupId); con.Open(); SqlDataReader dr = cmd.ExecuteReader(); obj.Employees = new List <UGOREmployeeDto>(); while (dr.Read()) { obj.Employees.Add(new UGOREmployeeDto() { EmployeeID = Convert.ToInt32(dr["EmployeeID"]), EmployeeCode = Convert.ToString(dr["EmployeeCode"]) }); } if (dr.NextResult()) { obj.GroupBanks = new List <UGORBankDto>(); while (dr.Read()) { obj.GroupBanks.Add(new UGORBankDto() { BankEntryId = Convert.ToInt32(dr["BankEntryID"]), BankCode = Convert.ToString(dr["BankCode"]) }); } if (dr.NextResult()) { obj.GroupMeetings = new List <UGORMeetingDto>(); while (dr.Read()) { obj.GroupMeetings.Add(new UGORMeetingDto() { MeetingDate = Convert.ToDateTime(dr["MeetingDate"]), isConducted = Convert.ToBoolean(dr["IsConducted"]) }); } if (dr.NextResult()) { obj.SlAccountHeads = new List <UGORAccountHeadDto>(); while (dr.Read()) { obj.SlAccountHeads.Add(new UGORAccountHeadDto() { AHCode = Convert.ToString(dr["AHCode"]), AHId = Convert.ToInt32(dr["AHID"]) }); } if (dr.NextResult()) { if (dr.Read()) { obj.MeetingMonth = Convert.ToInt32(dr["MeetingMonth"]); obj.MeetingYear = Convert.ToInt32(dr["MeetingYear"]); } } } } } } catch (Exception ex) { throw ex; } return(obj); }