public OtherInvoiceType GetOtherInvoiceByTypeId(int TypeID) { OtherInvoiceType invType = new OtherInvoiceType(); try { using (SqlConnection connection = DataAccess.CreateConnection()) { SqlCommand command = DataAccess.CreateCommand(connection); DataAccess.CreateStoredprocedure(command, "GetOtherInvoiceByTypeId_SP"); DataAccess.AddInParameter(command, "@TypeID", SqlDbType.Int, TypeID); SqlDataReader reader = DataAccess.ExecuteReader(command); if (reader != null) { while (reader.Read()) { invType.Id = reader["Id"] is DBNull ? 0 : Convert.ToInt32(reader["Id"]); invType.CreatedOn = reader["CreatedOn"] is DBNull ? DateTime.MinValue : Convert.ToDateTime(reader["CreatedOn"]); invType.InvoiceType = reader["InvoiceType"] is DBNull ? string.Empty : (String)reader["InvoiceType"]; invType.ApplicationUserId = reader["ApplicationUserId"] is DBNull ? string.Empty : (String)reader["ApplicationUserId"]; } } reader.Close(); return(invType); } } catch (Exception ex) { return(invType); } }
public ActionResult EditType(OtherInvoiceType model) { if (!ModelState.IsValid) { return(RedirectToAction("InvoiceTypes", "OtherInvoice")); } bool status = new OtherInvoiceDA().UpdateOtherInvoiceType(model); return(RedirectToAction("InvoiceTypes", "OtherInvoice")); }
public ActionResult CreateType(string InvoiceType) { if (!ModelState.IsValid) { return(RedirectToAction("InvoiceTypes", "OtherInvoice")); } OtherInvoiceType model = new OtherInvoiceType(); model.CreatedOn = DateTime.Now; model.InvoiceType = InvoiceType; model.ApplicationUserId = User.Identity.GetUserId(); bool status = new OtherInvoiceDA().InsertOtherInvoiceType(model); return(RedirectToAction("InvoiceTypes", "OtherInvoice")); }
public bool UpdateOtherInvoiceType(OtherInvoiceType model) { try { int status = 0; using (SqlConnection connection = DataAccess.CreateConnection()) { SqlCommand command = DataAccess.CreateCommand(connection); DataAccess.CreateStoredprocedure(command, "UpdateOtherInvoiceType_SP"); DataAccess.AddInParameter(command, "@TableId", SqlDbType.Int, model.Id); DataAccess.AddInParameter(command, "@InvoiceType", SqlDbType.VarChar, model.InvoiceType); status = DataAccess.ExecuteNonQuery(command); return(status < 0 ? false : true); } } catch (Exception ex) { return(false); } }